[llvm-commits] [llvm] r142066 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Duncan Sands
baldrick at free.fr
Sat Oct 15 04:13:42 PDT 2011
Author: baldrick
Date: Sat Oct 15 06:13:42 2011
New Revision: 142066
URL: http://llvm.org/viewvc/llvm-project?rev=142066&view=rev
Log:
Don't replace all dominated uses if there is only one use, since that
use can't be dominated, saving one domtree lookup.
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=142066&r1=142065&r2=142066&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sat Oct 15 06:13:42 2011
@@ -1935,10 +1935,15 @@
// 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
More information about the llvm-commits
mailing list