[llvm-commits] CVS: llvm/lib/Transforms/Utils/Local.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu May 5 22:27:51 PDT 2005
Changes in directory llvm/lib/Transforms/Utils:
Local.cpp updated: 1.38 -> 1.39
---
Log message:
DCE intrinsic instructions without side effects.
---
Diffs of the changes: (+20 -1)
Local.cpp | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletion(-)
Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.38 llvm/lib/Transforms/Utils/Local.cpp:1.39
--- llvm/lib/Transforms/Utils/Local.cpp:1.38 Fri Apr 29 00:55:35 2005
+++ llvm/lib/Transforms/Utils/Local.cpp Fri May 6 00:27:34 2005
@@ -373,7 +373,26 @@
//
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
More information about the llvm-commits
mailing list