summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-06 05:27:34 +0000
committerChris Lattner <sabre@nondot.org>2005-05-06 05:27:34 +0000
commitec710c5b12af647ae90f53917122726269c18738 (patch)
treeb52f8aa1a74a648ffd031f6628800622a0e44eee /lib/Transforms/Utils/Local.cpp
parent998fffdda1109dc603e0cae32f745ae8c8b640d4 (diff)
downloadllvm-ec710c5b12af647ae90f53917122726269c18738.tar.gz
llvm-ec710c5b12af647ae90f53917122726269c18738.tar.bz2
llvm-ec710c5b12af647ae90f53917122726269c18738.tar.xz
DCE intrinsic instructions without side effects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/Local.cpp')
-rw-r--r--lib/Transforms/Utils/Local.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 4d141533b8..0ed669643e 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -373,7 +373,26 @@ Constant *llvm::ConstantFoldCall(Function *F,
//
bool llvm::isInstructionTriviallyDead(Instruction *I) {
- return I->use_empty() && !I->mayWriteToMemory() && !isa<TerminatorInst>(I);
+ if (!I->use_empty() || isa<TerminatorInst>(I)) return false;
+
+ if (!I->mayWriteToMemory()) return true;
+
+ if (CallInst *CI = dyn_cast<CallInst>(I))
+ if (Function *F = CI->getCalledFunction())
+ switch (F->getIntrinsicID()) {
+ default: break;
+ case Intrinsic::vastart:
+ case Intrinsic::vacopy:
+ case Intrinsic::returnaddress:
+ case Intrinsic::frameaddress:
+ case Intrinsic::isunordered:
+ case Intrinsic::ctpop:
+ case Intrinsic::ctlz:
+ case Intrinsic::cttz:
+ case Intrinsic::sqrt:
+ return true; // These intrinsics have no side effects.
+ }
+ return false;
}
// dceInstruction - Inspect the instruction at *BBI and figure out if it's