summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nouveau
diff options
context:
space:
mode:
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>2014-09-05 23:52:45 +0200
committerEmil Velikov <emil.l.velikov@gmail.com>2014-09-09 21:29:28 +0100
commitf10161e477af21eb6723129c3f525a4b5126a973 (patch)
treec08a1bca98affc0698fe58eb775a168498745927 /src/gallium/drivers/nouveau
parent3f570286fc220fb898d5d41e4ff8a6e3ce862f1a (diff)
nv50/ir/util: fix BitSet issues
BitSet::allocate() is being used with the expectation that it would leave the bitfield untouched if its size hasn't changed, however, the function always zeroed the last word, which led to obscure bugs with live set computation. This also fixes BitSet::resize(), which was broken, but luckily not being used. Cc: "10.2 10.3" <mesa-stable@lists.freedesktop.org> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> (cherry picked from commit b9f9e3ce03dbd8d044a72a00e1e8856a500b5f72)
Diffstat (limited to 'src/gallium/drivers/nouveau')
-rw-r--r--src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp4
-rw-r--r--src/gallium/drivers/nouveau/codegen/nv50_ir_util.cpp8
-rw-r--r--src/gallium/drivers/nouveau/codegen/nv50_ir_util.h1
3 files changed, 10 insertions, 3 deletions
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
index b2840814424..f2a8b551407 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
@@ -1654,6 +1654,10 @@ RegAlloc::execFunc()
ret && i <= func->loopNestingBound;
sequence = func->cfg.nextSequence(), ++i)
ret = buildLiveSets(BasicBlock::get(func->cfg.getRoot()));
+ // reset marker
+ for (ArrayList::Iterator bi = func->allBBlocks.iterator();
+ !bi.end(); bi.next())
+ BasicBlock::get(bi)->liveSet.marker = false;
if (!ret)
break;
func->orderInstructions(this->insns);
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_util.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_util.cpp
index 895977710ca..d26acb304bc 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_util.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_util.cpp
@@ -254,7 +254,9 @@ bool BitSet::resize(unsigned int nBits)
return false;
}
if (n > p)
- memset(&data[4 * p + 4], 0, (n - p) * 4);
+ memset(&data[p], 0, (n - p) * 4);
+ if (nBits < size && (nBits % 32))
+ data[(nBits + 31) / 32 - 1] &= (1 << (nBits % 32)) - 1;
size = nBits;
return true;
@@ -274,8 +276,8 @@ bool BitSet::allocate(unsigned int nBits, bool zero)
if (zero)
memset(data, 0, (size + 7) / 8);
else
- if (nBits)
- data[(size + 31) / 32 - 1] = 0; // clear unused bits (e.g. for popCount)
+ if (size % 32) // clear unused bits (e.g. for popCount)
+ data[(size + 31) / 32 - 1] &= (1 << (size % 32)) - 1;
return data;
}
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h
index a4ea9d981e0..fa2c4804a42 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_util.h
@@ -484,6 +484,7 @@ public:
FREE(data);
}
+ // allocate will keep old data iff size is unchanged
bool allocate(unsigned int nBits, bool zero);
bool resize(unsigned int nBits); // keep old data, zero additional bits