[llvm] [LAA] Be more careful when evaluating AddRecs at symbolic max BTC. (PR #106530)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 06:30:03 PDT 2024
================
@@ -219,13 +219,29 @@ static std::pair<const SCEV *, const SCEV *> getStartAndEndForAccess(
const SCEV *ScStart;
const SCEV *ScEnd;
+ auto &DL = Lp->getHeader()->getDataLayout();
+ Type *IdxTy = DL.getIndexType(PtrExpr->getType());
+ const SCEV *EltSizeSCEV = SE->getStoreSizeOfExpr(IdxTy, AccessTy);
if (SE->isLoopInvariant(PtrExpr, Lp)) {
ScStart = ScEnd = PtrExpr;
} else if (auto *AR = dyn_cast<SCEVAddRecExpr>(PtrExpr)) {
- const SCEV *Ex = PSE.getSymbolicMaxBackedgeTakenCount();
-
ScStart = AR->getStart();
- ScEnd = AR->evaluateAtIteration(Ex, *SE);
+ const SCEV *BTC = PSE.getBackedgeTakenCount();
+ if (!isa<SCEVCouldNotCompute>(BTC))
+ ScEnd = AR->evaluateAtIteration(BTC, *SE);
----------------
david-arm wrote:
Why do we not have to worry about wrapping for this case? The value for BTC may not be constant and may also be an expression I think.
https://github.com/llvm/llvm-project/pull/106530
More information about the llvm-commits
mailing list