From 398f70292c4140b27f0799e89e2c34a38c2d9f7d Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 9 Jun 2006 00:12:42 +0000 Subject: RewriteExpr, either the new PHI node of induction variable or the post-increment value, should be first cast to the appropriated type (to the type of the common expr). Otherwise, the rewrite of a use based on (common + iv) may end up with an incorrect type. llvm-svn: 28735 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/Transforms/Scalar') diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index d3ac797651f..6e4460b509e 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1074,6 +1074,9 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride, if (L->contains(User.Inst->getParent())) User.Inst->moveBefore(LatchBlock->getTerminator()); } + if (RewriteOp->getType() != ReplacedTy) + RewriteOp = SCEVExpander::InsertCastOfTo(RewriteOp, ReplacedTy); + SCEVHandle RewriteExpr = SCEVUnknown::get(RewriteOp); // Clear the SCEVExpander's expression map so that we are guaranteed -- cgit v1.2.3