diff options
| author | Dan Gohman <gohman@apple.com> | 2009-05-27 20:00:18 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-05-27 20:00:18 +0000 |
| commit | f4d85325c09c23cd4f06e9121650926a767788fd (patch) | |
| tree | fae6158c31a803293b90cf06d056732802b6d2f1 /llvm/lib/Transforms | |
| parent | 7c1baf46d6897f03b9c20dbf2b2161e871c58697 (diff) | |
| download | bcm5719-llvm-f4d85325c09c23cd4f06e9121650926a767788fd.tar.gz bcm5719-llvm-f4d85325c09c23cd4f06e9121650926a767788fd.zip | |
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.
llvm-svn: 72493
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index adfa5272a9c..834a95d7318 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/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; } |

