summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-10-04 21:27:06 +0000
committerHal Finkel <hfinkel@anl.gov>2014-10-04 21:27:06 +0000
commit04a156139e03fc42354b8e538feab6ea08be1a78 (patch)
treea30ef39bb221aec9901745a88050921cdebd4d00 /llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
parent115547464e7c8fc0b2a297fe2b313a7974d670bd (diff)
downloadbcm5719-llvm-04a156139e03fc42354b8e538feab6ea08be1a78.tar.gz
bcm5719-llvm-04a156139e03fc42354b8e538feab6ea08be1a78.zip
[InstCombine] Remove redundant @llvm.assume intrinsics
For any @llvm.assume intrinsic, if there is another which dominates it and uses the same condition, then it is redundant and can be removed. While this does not alter the semantics of the @llvm.assume intrinsics, it makes subsequent handling more efficient (and the resulting IR easier to read). llvm-svn: 219067
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 30fc3c93383..27a64d8bcde 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -16,6 +16,7 @@
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Dominators.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/Local.h"
@@ -1016,6 +1017,22 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
II->getName());
return EraseInstFromFunction(*II);
}
+
+ // If there is a dominating assume with the same condition as this one,
+ // then this one is redundant, and should be removed.
+ if (DT) {
+ for (User *U : IIOperand->users()) {
+ Instruction *User = dyn_cast<Instruction>(U);
+ if (!User || User == II)
+ continue;
+
+ if (match(User,
+ m_Intrinsic<Intrinsic::assume>(m_Specific(IIOperand))) &&
+ DT->dominates(User, II))
+ return EraseInstFromFunction(*II);
+ }
+ }
+
break;
}
}
OpenPOWER on IntegriCloud