From ca1fc2b86400e3fc9dd0517863e22721b5e91c77 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Tue, 7 Feb 2012 20:45:03 +0100 Subject: [PATCH] nv50/ir/opt: don't replace conditional definitions in CSE --- src/gallium/drivers/nv50/codegen/nv50_ir.h | 1 + src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) 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; } -- 2.30.2