X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FTransforms%2FScalar%2FGVN.cpp;h=18a9661684f35c72d7e27c2938979d4c3bc2a80e;hb=c45996bf7464d4b5bc038abeff362f47fea401d9;hp=498785e327a4b1536b9ca4a6915a8d01bd6721cc;hpb=cb29a4f66a837c2d322ca08d4bcde7440a6f5cdc;p=oota-llvm.git diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 498785e327a..18a9661684f 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -166,6 +166,7 @@ namespace { void setAliasAnalysis(AliasAnalysis* A) { AA = A; } void setMemDep(MemoryDependenceAnalysis* M) { MD = M; } void setDomTree(DominatorTree* D) { DT = D; } + uint32_t getNextUnusedValueNumber() { return nextValueNumber; } }; } @@ -1058,11 +1059,12 @@ bool GVN::processInstruction(Instruction *I, return changed; } + uint32_t nextNum = VN.getNextUnusedValueNumber(); unsigned num = VN.lookup_or_add(I); // Allocations are always uniquely numbered, so we can save time and memory // by fast failing them. - if (isa(I)) { + if (isa(I) || isa(I)) { localAvail[I->getParent()]->table.insert(std::make_pair(num, I)); return false; } @@ -1082,6 +1084,13 @@ bool GVN::processInstruction(Instruction *I, } else { localAvail[I->getParent()]->table.insert(std::make_pair(num, I)); } + + // If the number we were assigned was a brand new VN, then we don't + // need to do a lookup to see if the number already exists + // somewhere in the domtree: it can't! + } else if (num == nextNum) { + localAvail[I->getParent()]->table.insert(std::make_pair(num, I)); + // Perform value-number based elimination } else if (Value* repl = lookupNumber(I->getParent(), num)) { // Remove it! @@ -1092,7 +1101,7 @@ bool GVN::processInstruction(Instruction *I, I->replaceAllUsesWith(repl); toErase.push_back(I); return true; - } else if (!I->isTerminator()) { + } else { localAvail[I->getParent()]->table.insert(std::make_pair(num, I)); } @@ -1258,11 +1267,14 @@ bool GVN::performPRE(Function& F) { Value* op = BI->getOperand(i); if (isa(op) || isa(op) || isa(op)) PREInstr->setOperand(i, op); - else if (!lookupNumber(PREPred, VN.lookup(op))) { - success = false; - break; - } else - PREInstr->setOperand(i, lookupNumber(PREPred, VN.lookup(op))); + else { + Value* V = lookupNumber(PREPred, VN.lookup(op)); + if (!V) { + success = false; + break; + } else + PREInstr->setOperand(i, V); + } } // Fail out if we encounter an operand that is not available in