summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Bumiller <[email protected]>2012-02-07 20:45:03 +0100
committerChristoph Bumiller <[email protected]>2012-04-14 21:54:02 +0200
commitca1fc2b86400e3fc9dd0517863e22721b5e91c77 (patch)
tree0b2ab5d7ee2ab89314fb0ab1d9e7dd6ea5802e6c
parent90f0fac65524fbc4e2f2d396d20d9808e4a0a95c (diff)
nv50/ir/opt: don't replace conditional definitions in CSE
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir.h1
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.h b/src/gallium/drivers/nv50/codegen/nv50_ir.h
index b582a468b31..93e3008cf0d 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir.h
@@ -616,6 +616,7 @@ public:
bool setPredicate(CondCode ccode, Value *);
inline Value *getPredicate() const;
bool writesPredicate() const;
+ inline bool isPredicated() const { return predSrc >= 0; }
inline void setFlagsSrc(int s, Value *);
inline void setFlagsDef(int d, Value *);
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
index c2c33e20bf1..5f974436e94 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
@@ -2009,6 +2009,8 @@ GlobalCSE::visit(BasicBlock *bb)
Instruction *phi, *next, *ik;
int s;
+ // TODO: maybe do this with OP_UNION, too
+
for (phi = bb->getPhi(); phi && phi->op == OP_PHI; phi = next) {
next = phi->next;
if (phi->getSrc(0)->refCount() > 1)
@@ -2040,8 +2042,14 @@ bool
LocalCSE::tryReplace(Instruction **ptr, Instruction *i)
{
Instruction *old = *ptr;
+
+ // TODO: maybe relax this later (causes trouble with OP_UNION)
+ if (i->isPredicated())
+ return false;
+
if (!old->isResultEqual(i))
return false;
+
for (int d = 0; old->defExists(d); ++d)
old->def(d).replace(i->getDef(d), false);
delete_Instruction(prog, old);
@@ -2241,6 +2249,7 @@ Program::optimizeSSA(int level)
RUN_PASS(2, MemoryOpt, run);
RUN_PASS(2, LocalCSE, run);
RUN_PASS(0, DeadCodeElim, buryAll);
+
return true;
}