diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-13 20:11:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-13 20:11:04 +0000 |
commit | 8b0ea313d9cdbb43154b52a004ea4a1dfa43a0b5 (patch) | |
tree | 643d05292080b7913e99d6b8bf9fb311525f054d /lib/Transforms | |
parent | b419b0e68220296dbae8016d35718f55c39244c1 (diff) |
Simplify this a tiny bit by using the new IntrinsicInst functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25292 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 1f59f4c45b..b326220499 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4620,12 +4620,17 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { } -// CallInst simplification -// +/// visitCallInst - CallInst simplification. This mostly only handles folding +/// of intrinsic instructions. For normal calls, it allows visitCallSite to do +/// the heavy lifting. +/// Instruction *InstCombiner::visitCallInst(CallInst &CI) { + IntrinsicInst *II = dyn_cast<IntrinsicInst>(&CI); + if (!II) return visitCallSite(&CI); + // Intrinsics cannot occur in an invoke, so handle them here instead of in // visitCallSite. - if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(&CI)) { + if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(II)) { bool Changed = false; // memmove/cpy/set of zero bytes is a noop. @@ -4645,7 +4650,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { // If we have a memmove and the source operation is a constant global, // then the source and dest pointers can't alias, so we can change this // into a call to memcpy. - if (MemMoveInst *MMI = dyn_cast<MemMoveInst>(MI)) + if (MemMoveInst *MMI = dyn_cast<MemMoveInst>(II)) if (GlobalVariable *GVSrc = dyn_cast<GlobalVariable>(MMI->getSource())) if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); @@ -4655,8 +4660,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { Changed = true; } - if (Changed) return &CI; - } else if (DbgStopPointInst *SPI = dyn_cast<DbgStopPointInst>(&CI)) { + if (Changed) return II; + } else if (DbgStopPointInst *SPI = dyn_cast<DbgStopPointInst>(II)) { // If this stoppoint is at the same source location as the previous // stoppoint in the chain, it is not needed. if (DbgStopPointInst *PrevSPI = @@ -4668,7 +4673,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { } } - return visitCallSite(&CI); + return visitCallSite(II); } // InvokeInst simplification |