summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-02-27 12:11:41 +0000
committerDuncan Sands <baldrick@free.fr>2012-02-27 12:11:41 +0000
commit9edea84420f2d9d7e08dfc370eeca51b7ea4870d (patch)
tree4c53b39ce16a7f8f015289ea5a488043c293ddd0 /llvm/lib/Transforms
parent8e9d47c039b56e457ed2578e75fec2e40eeae664 (diff)
downloadbcm5719-llvm-9edea84420f2d9d7e08dfc370eeca51b7ea4870d.tar.gz
bcm5719-llvm-9edea84420f2d9d7e08dfc370eeca51b7ea4870d.zip
Micro-optimization, no functionality change.
llvm-svn: 151524
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 06a8be0ba21..702d1d700e7 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2041,13 +2041,18 @@ bool GVN::propagateEquality(Value *LHS, Value *RHS, BasicBlock *Root) {
// 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.
OpenPOWER on IntegriCloud