[llvm-commits] [llvm] r151524 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Duncan Sands
baldrick at free.fr
Mon Feb 27 04:11:41 PST 2012
Author: baldrick
Date: Mon Feb 27 06:11:41 2012
New Revision: 151524
URL: http://llvm.org/viewvc/llvm-project?rev=151524&view=rev
Log:
Micro-optimization, no functionality change.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=151524&r1=151523&r2=151524&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Feb 27 06:11:41 2012
@@ -2041,13 +2041,18 @@
// Since we don't have the instruction "A < B" immediately to hand, work out
// the value number that it would have and use that to find an appropriate
// instruction (if any).
- unsigned Num = VN.lookup_or_add_cmp(Cmp->getOpcode(), NotPred, Op0, Op1);
- Value *NotCmp = findLeader(Root, Num);
- if (NotCmp && isa<Instruction>(NotCmp)) {
- unsigned NumReplacements =
- replaceAllDominatedUsesWith(NotCmp, NotVal, Root);
- Changed |= NumReplacements > 0;
- NumGVNEqProp += NumReplacements;
+ uint32_t NextNum = VN.getNextUnusedValueNumber();
+ uint32_t Num = VN.lookup_or_add_cmp(Cmp->getOpcode(), NotPred, Op0, Op1);
+ // If the number we were assigned was brand new then there is no point in
+ // looking for an instruction realizing it: there cannot be one!
+ if (Num < NextNum) {
+ Value *NotCmp = findLeader(Root, Num);
+ if (NotCmp && isa<Instruction>(NotCmp)) {
+ unsigned NumReplacements =
+ replaceAllDominatedUsesWith(NotCmp, NotVal, Root);
+ Changed |= NumReplacements > 0;
+ NumGVNEqProp += NumReplacements;
+ }
}
// Ensure that any instruction in scope that gets the "A < B" value number
// is replaced with false.
More information about the llvm-commits
mailing list