diff options
author | Dan Gohman <gohman@apple.com> | 2009-05-27 21:10:47 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-05-27 21:10:47 +0000 |
commit | c2695eba5700c785c2ae144eede7e1a932e3f5f3 (patch) | |
tree | 9c84f7b55133a8f66c4b88fb694b3509ac6695ac /lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | ba2352b0663e718855d1898fab6d3308dedd14fc (diff) | |
download | external_llvm-c2695eba5700c785c2ae144eede7e1a932e3f5f3.zip external_llvm-c2695eba5700c785c2ae144eede7e1a932e3f5f3.tar.gz external_llvm-c2695eba5700c785c2ae144eede7e1a932e3f5f3.tar.bz2 |
Revert 72493 and replace it with a more conservative fix, for now: don't
rewrite the comparison if there is any implicit extension or truncation
on the induction variable. I'm planning for IVUsers to eventually take
over some of the work of this code, and for it to be generalized.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72496 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 834a95d..92270b5 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1993,6 +1993,12 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond, ValidScale(!CommonExprs->isZero(), Scale, UsersToProcess)) continue; + // Avoid rewriting the compare instruction with an iv which has + // implicit extension or truncation built into it. + // TODO: This is over-conservative. + if (SE->getTypeSizeInBits(CondUse->getOffset()->getType()) != TyBits) + continue; + // If scale is negative, use swapped predicate unless it's testing // for equality. if (Scale < 0 && !Cond->isEquality()) @@ -2005,16 +2011,11 @@ 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(NewOffset, + ? SE->getMulExpr(CondUse->getOffset(), SE->getConstant(ConstantInt::get(CmpTy, Scale))) : SE->getConstant(ConstantInt::get(NewCmpIntTy, - cast<SCEVConstant>(NewOffset)->getValue() + cast<SCEVConstant>(CondUse->getOffset())->getValue() ->getSExtValue()*Scale)); break; } |