[llvm-commits] [llvm] r69290 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Dan Gohman
gohman at apple.com
Thu Apr 16 08:47:35 PDT 2009
Author: djg
Date: Thu Apr 16 10:47:35 2009
New Revision: 69290
URL: http://llvm.org/viewvc/llvm-project?rev=69290&view=rev
Log:
Use a SCEV expression cast instead of immediately inserting a
new instruction with SCEVExpander::InsertCastOfTo.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=69290&r1=69289&r2=69290&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Apr 16 10:47:35 2009
@@ -1836,17 +1836,17 @@
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
More information about the llvm-commits
mailing list