Skip to content

Commit 75a85c8

Browse files
committed
[LAA] Simplify GEP SCEV in findForkedSCEVs (NFC)
1 parent 3764ba2 commit 75a85c8

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -999,23 +999,16 @@ static void findForkedSCEVs(
999999
break;
10001000
}
10011001

1002-
// Find the pointer type we need to extend to.
1003-
Type *IntPtrTy = SE->getEffectiveSCEVType(
1004-
SE->getSCEV(GEP->getPointerOperand())->getType());
1005-
1006-
// Find the size of the type being pointed to. We only have a single
1007-
// index term (guarded above) so we don't need to index into arrays or
1008-
// structures, just get the size of the scalar value.
1009-
const SCEV *Size = SE->getSizeOfExpr(IntPtrTy, SourceTy);
1010-
10111002
// Scale up the offsets by the size of the type, then add to the bases.
1003+
const SCEV *Offset0 = get<0>(OffsetScevs[0]);
1004+
const SCEV *Offset1 = get<0>(OffsetScevs[1]);
1005+
const SCEV *Scaled0 = SE->getMulExpr(
1006+
SE->getSizeOfExpr(Offset0->getType(), SourceTy), Offset0);
10121007
const SCEV *Scaled1 = SE->getMulExpr(
1013-
Size, SE->getTruncateOrSignExtend(get<0>(OffsetScevs[0]), IntPtrTy));
1014-
const SCEV *Scaled2 = SE->getMulExpr(
1015-
Size, SE->getTruncateOrSignExtend(get<0>(OffsetScevs[1]), IntPtrTy));
1016-
ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[0]), Scaled1),
1008+
SE->getSizeOfExpr(Offset1->getType(), SourceTy), Offset1);
1009+
ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[0]), Scaled0),
10171010
NeedsFreeze);
1018-
ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[1]), Scaled2),
1011+
ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[1]), Scaled1),
10191012
NeedsFreeze);
10201013
break;
10211014
}

0 commit comments

Comments
 (0)