summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-10-15 11:13:42 +0000
committerDuncan Sands <baldrick@free.fr>2011-10-15 11:13:42 +0000
commit1673b15da2d908e0ea9fd2d64f61d6d226cfe16e (patch)
tree9007d5fb98a8a2af011af018194a873ef1291c3d /lib/Transforms
parent6e6a558ebce556476d8fd659b419a2760f2ab154 (diff)
downloadllvm-1673b15da2d908e0ea9fd2d64f61d6d226cfe16e.tar.gz
llvm-1673b15da2d908e0ea9fd2d64f61d6d226cfe16e.tar.bz2
llvm-1673b15da2d908e0ea9fd2d64f61d6d226cfe16e.tar.xz
Don't replace all dominated uses if there is only one use, since that
use can't be dominated, saving one domtree lookup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142066 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/GVN.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index cbfdbcddae..a51cbb631b 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1935,10 +1935,15 @@ bool GVN::propagateEquality(Value *LHS, Value *RHS, BasicBlock *Root) {
// to 'LHS' then ensure it will be turned into 'RHS'.
addToLeaderTable(VN.lookup_or_add(LHS), RHS, Root);
- // Replace all occurrences of 'LHS' with 'RHS' everywhere in the scope.
- unsigned NumReplacements = replaceAllDominatedUsesWith(LHS, RHS, Root);
- bool Changed = NumReplacements > 0;
- NumGVNEqProp += NumReplacements;
+ // Replace all occurrences of 'LHS' with 'RHS' everywhere in the scope. As
+ // LHS always has at least one use that is not dominated by Root, this will
+ // never do anything if LHS has only one use.
+ bool Changed = false;
+ if (!LHS->hasOneUse()) {
+ unsigned NumReplacements = replaceAllDominatedUsesWith(LHS, RHS, Root);
+ Changed |= NumReplacements > 0;
+ NumGVNEqProp += NumReplacements;
+ }
// Now try to deduce additional equalities from this one. For example, if the
// known equality was "(A != B)" == "false" then it follows that A and B are