nv50/ir/opt: don't replace conditional definitions in CSE

This commit is contained in:
Christoph Bumiller 2012-02-07 20:45:03 +01:00
parent 90f0fac655
commit ca1fc2b864
2 changed files with 10 additions and 0 deletions

View File

@ -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 *);

View File

@ -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;
}