[llvm] 18507a7 - [DA] Remove base pointers from subscripts (NFCI) (#157083)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 05:38:28 PDT 2025
Author: Ryotaro Kasuga
Date: 2025-09-16T12:38:24Z
New Revision: 18507a7a6bf1c82e2614b3995320ebab8dd60ef2
URL: https://github.com/llvm/llvm-project/commit/18507a7a6bf1c82e2614b3995320ebab8dd60ef2
DIFF: https://github.com/llvm/llvm-project/commit/18507a7a6bf1c82e2614b3995320ebab8dd60ef2.diff
LOG: [DA] Remove base pointers from subscripts (NFCI) (#157083)
This patch removes base pointers from subscripts when delinearization
fails. Previously, in such cases, the pointer type SCEVs were used
instead of offset SCEVs derived from them.
For example, here is a portion of the debug output when analyzing
`strong0` in `test/Analysis/DependenceAnalysis/StrongSIV.ll`:
```
testing subscript 0, SIV
src = {(8 + %A),+,4}<nuw><%for.body>
dst = {(8 + %A),+,4}<nuw><%for.body>
Strong SIV test
Coeff = 4, i64
SrcConst = (8 + %A), ptr
DstConst = (8 + %A), ptr
Delta = 0, i64
UpperBound = (-1 + %n), i64
Distance = 0
Remainder = 0
```
As shown above, the `SrcConst` and `DstConst` are pointer values rather
than integer offsets. `%A` should be removed.
This change is necessary for #157086, since
`ScalarEvolution::willNotOverflow` expects integer type SCEVs as
arguments. This change alone alone should not affect the analysis
results.
Added:
Modified:
llvm/lib/Analysis/DependenceAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index da86a8d2cc9c0..43eefc3120f9e 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -3698,8 +3698,8 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
unsigned Pairs = 1;
SmallVector<Subscript, 2> Pair(Pairs);
- Pair[0].Src = SrcSCEV;
- Pair[0].Dst = DstSCEV;
+ Pair[0].Src = SrcEv;
+ Pair[0].Dst = DstEv;
if (Delinearize) {
if (tryDelinearize(Src, Dst, Pair)) {
@@ -3709,6 +3709,8 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
}
for (unsigned P = 0; P < Pairs; ++P) {
+ assert(Pair[P].Src->getType()->isIntegerTy() && "Src must be an integer");
+ assert(Pair[P].Dst->getType()->isIntegerTy() && "Dst must be an integer");
Pair[P].Loops.resize(MaxLevels + 1);
Pair[P].GroupLoops.resize(MaxLevels + 1);
Pair[P].Group.resize(Pairs);
@@ -4111,8 +4113,8 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
SmallVector<Subscript, 2> Pair(Pairs);
const SCEV *SrcSCEV = SE->getSCEV(SrcPtr);
const SCEV *DstSCEV = SE->getSCEV(DstPtr);
- Pair[0].Src = SrcSCEV;
- Pair[0].Dst = DstSCEV;
+ Pair[0].Src = SE->removePointerBase(SrcSCEV);
+ Pair[0].Dst = SE->removePointerBase(DstSCEV);
if (Delinearize) {
if (tryDelinearize(Src, Dst, Pair)) {
@@ -4122,6 +4124,8 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
}
for (unsigned P = 0; P < Pairs; ++P) {
+ assert(Pair[P].Src->getType()->isIntegerTy() && "Src must be an integer");
+ assert(Pair[P].Dst->getType()->isIntegerTy() && "Dst must be an integer");
Pair[P].Loops.resize(MaxLevels + 1);
Pair[P].GroupLoops.resize(MaxLevels + 1);
Pair[P].Group.resize(Pairs);
More information about the llvm-commits
mailing list