Skip to content

Commit 32c640b

Browse files
kasuga-fjdvbuka
authored andcommitted
[LoopCacheAnalysis] Drop incorrect nowrap flags from addrec (llvm#164796)
This patch stops propagating nowrap flags unconditionally. In the modified part, when we have an addrec `{%a,+,%b}` where `%b` is known to be negative, we create a new addrec `{%a,+,(-1 * %b)}`. When creating it, the nowrap flags are transferred from the original addrec to the new one without any checks, which is generally incorrect. Since the nowrap property is not essential for this analysis, it would be better to drop it to avoid potential bugs.
1 parent 2ddce4a commit 32c640b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/lib/Analysis/LoopCacheAnalysis.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,9 @@ bool IndexedReference::delinearize(const LoopInfo &LI) {
436436
const SCEV *StepRec = AccessFnAR ? AccessFnAR->getStepRecurrence(SE) : nullptr;
437437

438438
if (StepRec && SE.isKnownNegative(StepRec))
439-
AccessFn = SE.getAddRecExpr(AccessFnAR->getStart(),
440-
SE.getNegativeSCEV(StepRec),
441-
AccessFnAR->getLoop(),
442-
AccessFnAR->getNoWrapFlags());
439+
AccessFn = SE.getAddRecExpr(
440+
AccessFnAR->getStart(), SE.getNegativeSCEV(StepRec),
441+
AccessFnAR->getLoop(), SCEV::NoWrapFlags::FlagAnyWrap);
443442
const SCEV *Div = SE.getUDivExactExpr(AccessFn, ElemSize);
444443
Subscripts.push_back(Div);
445444
Sizes.push_back(ElemSize);

0 commit comments

Comments
 (0)