aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/GVN.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-19 20:24:28 +0000
committerChris Lattner <sabre@nondot.org>2010-12-19 20:24:28 +0000
commit459f4f8c25bd0f61b76b61b19f4839e5790fad34 (patch)
tree05be0a093c7ffcaf62e310bfe64883664c300ec0 /lib/Transforms/Scalar/GVN.cpp
parent2a786eb030bbcbadc2fc7713b8933e6e8b383b28 (diff)
downloadexternal_llvm-459f4f8c25bd0f61b76b61b19f4839e5790fad34.zip
external_llvm-459f4f8c25bd0f61b76b61b19f4839e5790fad34.tar.gz
external_llvm-459f4f8c25bd0f61b76b61b19f4839e5790fad34.tar.bz2
tidy up
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/GVN.cpp')
-rw-r--r--lib/Transforms/Scalar/GVN.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 5ac19dc..85cc8d1 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1918,36 +1918,35 @@ bool GVN::processInstruction(Instruction *I,
// Allocations are always uniquely numbered, so we can save time and memory
// by fast failing them.
- if (isa<AllocaInst>(I) || isa<TerminatorInst>(I)) {
+ if (isa<AllocaInst>(I) || isa<TerminatorInst>(I) || isa<PHINode>(I)) {
insert_table(Num, I);
return false;
}
- if (isa<PHINode>(I)) {
- insert_table(Num, I);
-
// If the number we were assigned was a brand new VN, then we don't
// need to do a lookup to see if the number already exists
// somewhere in the domtree: it can't!
- } else if (Num == NextNum) {
+ if (Num == NextNum) {
insert_table(Num, I);
-
+ return false;
+ }
+
// Perform fast-path value-number based elimination of values inherited from
// dominators.
- } else if (Value *repl = lookupNumber(I->getParent(), Num)) {
- // Remove it!
- VN.erase(I);
- I->replaceAllUsesWith(repl);
- if (MD && repl->getType()->isPointerTy())
- MD->invalidateCachedPointerInfo(repl);
- toErase.push_back(I);
- return true;
-
- } else {
+ Value *repl = lookupNumber(I->getParent(), Num);
+ if (repl == 0) {
+ // Failure, just remember this instance for future use.
insert_table(Num, I);
+ return false;
}
-
- return false;
+
+ // Remove it!
+ VN.erase(I);
+ I->replaceAllUsesWith(repl);
+ if (MD && repl->getType()->isPointerTy())
+ MD->invalidateCachedPointerInfo(repl);
+ toErase.push_back(I);
+ return true;
}
/// runOnFunction - This is the main transformation entry point for a function.