From: Christoph Bumiller Date: Tue, 7 Feb 2012 19:45:03 +0000 (+0100) Subject: nv50/ir/opt: don't replace conditional definitions in CSE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ca1fc2b86400e3fc9dd0517863e22721b5e91c77;p=mesa.git nv50/ir/opt: don't replace conditional definitions in CSE --- 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; }