aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-05-27 20:00:18 +0000
committerDan Gohman <gohman@apple.com>2009-05-27 20:00:18 +0000
commitead28bd04bf42cdf8c29d12fa4c0f9d29a4c58cd (patch)
tree7cda959f58fdcdbb34927dbabccb80f8f139f630 /lib/Transforms/Scalar
parentbc9be219d69c705097867d4c2277e5aee3f82e7f (diff)
downloadexternal_llvm-ead28bd04bf42cdf8c29d12fa4c0f9d29a4c58cd.zip
external_llvm-ead28bd04bf42cdf8c29d12fa4c0f9d29a4c58cd.tar.gz
external_llvm-ead28bd04bf42cdf8c29d12fa4c0f9d29a4c58cd.tar.bz2
In ChangeCompareStride, when the stride to be reused is truncated to
a smaller type, promoted its offset back up to the type of the new comparison. This fixes PR4222. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72493 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index adfa527..834a95d 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2005,11 +2005,16 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
ConstantInt *CI = ConstantInt::get(NewCmpIntTy, NewCmpVal);
NewCmpRHS = ConstantExpr::getIntToPtr(CI, NewCmpTy);
}
+ NewOffset = CondUse->getOffset();
+ if (CondUse->isSigned())
+ NewOffset = SE->getNoopOrSignExtend(CondUse->getOffset(), NewCmpTy);
+ else
+ NewOffset = SE->getNoopOrZeroExtend(CondUse->getOffset(), NewCmpTy);
NewOffset = TyBits == NewTyBits
- ? SE->getMulExpr(CondUse->getOffset(),
+ ? SE->getMulExpr(NewOffset,
SE->getConstant(ConstantInt::get(CmpTy, Scale)))
: SE->getConstant(ConstantInt::get(NewCmpIntTy,
- cast<SCEVConstant>(CondUse->getOffset())->getValue()
+ cast<SCEVConstant>(NewOffset)->getValue()
->getSExtValue()*Scale));
break;
}