[llvm] c6073d7 - [LoopCacheAnalysis] Drop incorrect nowrap flags from addrec (#164796)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 23 08:32:38 PDT 2025
Author: Ryotaro Kasuga
Date: 2025-10-24T00:32:34+09:00
New Revision: c6073d72ee23d8cd6aa49c08edde846359e41bde
URL: https://github.com/llvm/llvm-project/commit/c6073d72ee23d8cd6aa49c08edde846359e41bde
DIFF: https://github.com/llvm/llvm-project/commit/c6073d72ee23d8cd6aa49c08edde846359e41bde.diff
LOG: [LoopCacheAnalysis] Drop incorrect nowrap flags from addrec (#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.
Added:
Modified:
llvm/lib/Analysis/LoopCacheAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
index 050c32707596a..424a7fe3721bb 100644
--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
@@ -436,10 +436,9 @@ bool IndexedReference::delinearize(const LoopInfo &LI) {
const SCEV *StepRec = AccessFnAR ? AccessFnAR->getStepRecurrence(SE) : nullptr;
if (StepRec && SE.isKnownNegative(StepRec))
- AccessFn = SE.getAddRecExpr(AccessFnAR->getStart(),
- SE.getNegativeSCEV(StepRec),
- AccessFnAR->getLoop(),
- AccessFnAR->getNoWrapFlags());
+ AccessFn = SE.getAddRecExpr(
+ AccessFnAR->getStart(), SE.getNegativeSCEV(StepRec),
+ AccessFnAR->getLoop(), SCEV::NoWrapFlags::FlagAnyWrap);
const SCEV *Div = SE.getUDivExactExpr(AccessFn, ElemSize);
Subscripts.push_back(Div);
Sizes.push_back(ElemSize);
More information about the llvm-commits
mailing list