From a36d52574196824d909d8ff7a2e7d467bf52313b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 6 May 2005 05:27:34 +0000 Subject: DCE intrinsic instructions without side effects. llvm-svn: 21719 --- llvm/lib/Transforms/Utils/Local.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Utils/Local.cpp') diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 4d141533b88..0ed669643e5 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/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(I); + if (!I->use_empty() || isa(I)) return false; + + if (!I->mayWriteToMemory()) return true; + + if (CallInst *CI = dyn_cast(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 -- cgit v1.2.3