aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-04-16 15:47:35 +0000
committerDan Gohman <gohman@apple.com>2009-04-16 15:47:35 +0000
commite616bf338a3669fad4bc3806547f70328eb2aa7e (patch)
tree83f742499593662a522a91d5845a32d61b4e328d /lib/Transforms/Scalar/LoopStrengthReduce.cpp
parent906caf2ae45455a12696bb950429da28d7d63422 (diff)
Use a SCEV expression cast instead of immediately inserting a
new instruction with SCEVExpander::InsertCastOfTo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69290 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index a542ca02a2..74b0d5a606 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1836,17 +1836,17 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
if (L->contains(User.Inst->getParent()))
User.Inst->moveBefore(LatchBlock->getTerminator());
}
- if (RewriteOp->getType() != ReplacedTy) {
- Instruction::CastOps opcode =
- CastInst::getCastOpcode(RewriteOp, false, ReplacedTy, false);
- assert(opcode != Instruction::SExt &&
- opcode != Instruction::ZExt &&
- "Unexpected widening cast!");
- RewriteOp = SCEVExpander::InsertCastOfTo(opcode, RewriteOp, ReplacedTy);
- }
SCEVHandle RewriteExpr = SE->getUnknown(RewriteOp);
+ if (TD->getTypeSizeInBits(RewriteOp->getType()) !=
+ TD->getTypeSizeInBits(ReplacedTy)) {
+ assert(TD->getTypeSizeInBits(RewriteOp->getType()) >
+ TD->getTypeSizeInBits(ReplacedTy) &&
+ "Unexpected widening cast!");
+ RewriteExpr = SE->getTruncateExpr(RewriteExpr, ReplacedTy);
+ }
+
// If we had to insert new instructions for RewriteOp, we have to
// consider that they may not have been able to end up immediately
// next to RewriteOp, because non-PHI instructions may never precede