mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Watch out for a constant offset cancelling out a base register, forming
a zero. This situation arrises in Fortran code with induction variables that start at 1 instead of 0. This fixes PR7651. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108424 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2362,7 +2362,7 @@ void LSRInstance::GenerateConstantOffsets(LSRUse &LU, unsigned LUIdx,
|
||||
Formula Base) {
|
||||
// TODO: For now, just add the min and max offset, because it usually isn't
|
||||
// worthwhile looking at everything inbetween.
|
||||
SmallVector<int64_t, 4> Worklist;
|
||||
SmallVector<int64_t, 2> Worklist;
|
||||
Worklist.push_back(LU.MinOffset);
|
||||
if (LU.MaxOffset != LU.MinOffset)
|
||||
Worklist.push_back(LU.MaxOffset);
|
||||
@@ -2376,7 +2376,14 @@ void LSRInstance::GenerateConstantOffsets(LSRUse &LU, unsigned LUIdx,
|
||||
F.AM.BaseOffs = (uint64_t)Base.AM.BaseOffs - *I;
|
||||
if (isLegalUse(F.AM, LU.MinOffset - *I, LU.MaxOffset - *I,
|
||||
LU.Kind, LU.AccessTy, TLI)) {
|
||||
F.BaseRegs[i] = SE.getAddExpr(G, SE.getConstant(G->getType(), *I));
|
||||
// Add the offset to the base register.
|
||||
const SCEV *NewG = SE.getAddExpr(G, SE.getConstant(G->getType(), *I));
|
||||
// If it cancelled out, drop the base register, otherwise update it.
|
||||
if (NewG->isZero()) {
|
||||
std::swap(F.BaseRegs[i], F.BaseRegs.back());
|
||||
F.BaseRegs.pop_back();
|
||||
} else
|
||||
F.BaseRegs[i] = NewG;
|
||||
|
||||
(void)InsertFormula(LU, LUIdx, F);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user