diff options
| author | Duncan Sands <baldrick@free.fr> | 2011-10-15 11:13:42 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2011-10-15 11:13:42 +0000 |
| commit | f537a6edd4522824b46e6ed2d33a8bd8ee6643c7 (patch) | |
| tree | 937a0e63b3c6d397e59bfa75909b993401821685 | |
| parent | 99eb7dc85f62b8d0c240c79d5138d834cab98e6c (diff) | |
| download | bcm5719-llvm-f537a6edd4522824b46e6ed2d33a8bd8ee6643c7.tar.gz bcm5719-llvm-f537a6edd4522824b46e6ed2d33a8bd8ee6643c7.zip | |
Don't replace all dominated uses if there is only one use, since that
use can't be dominated, saving one domtree lookup.
llvm-svn: 142066
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index cbfdbcddaec..a51cbb631ba 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/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 |

