mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-16 11:24:39 +00:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user