Skip to content

Commit 18507a7

Browse files
authored
[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.
1 parent c366cbd commit 18507a7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/Analysis/DependenceAnalysis.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3698,8 +3698,8 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36983698

36993699
unsigned Pairs = 1;
37003700
SmallVector<Subscript, 2> Pair(Pairs);
3701-
Pair[0].Src = SrcSCEV;
3702-
Pair[0].Dst = DstSCEV;
3701+
Pair[0].Src = SrcEv;
3702+
Pair[0].Dst = DstEv;
37033703

37043704
if (Delinearize) {
37053705
if (tryDelinearize(Src, Dst, Pair)) {
@@ -3709,6 +3709,8 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
37093709
}
37103710

37113711
for (unsigned P = 0; P < Pairs; ++P) {
3712+
assert(Pair[P].Src->getType()->isIntegerTy() && "Src must be an integer");
3713+
assert(Pair[P].Dst->getType()->isIntegerTy() && "Dst must be an integer");
37123714
Pair[P].Loops.resize(MaxLevels + 1);
37133715
Pair[P].GroupLoops.resize(MaxLevels + 1);
37143716
Pair[P].Group.resize(Pairs);
@@ -4111,8 +4113,8 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
41114113
SmallVector<Subscript, 2> Pair(Pairs);
41124114
const SCEV *SrcSCEV = SE->getSCEV(SrcPtr);
41134115
const SCEV *DstSCEV = SE->getSCEV(DstPtr);
4114-
Pair[0].Src = SrcSCEV;
4115-
Pair[0].Dst = DstSCEV;
4116+
Pair[0].Src = SE->removePointerBase(SrcSCEV);
4117+
Pair[0].Dst = SE->removePointerBase(DstSCEV);
41164118

41174119
if (Delinearize) {
41184120
if (tryDelinearize(Src, Dst, Pair)) {
@@ -4122,6 +4124,8 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
41224124
}
41234125

41244126
for (unsigned P = 0; P < Pairs; ++P) {
4127+
assert(Pair[P].Src->getType()->isIntegerTy() && "Src must be an integer");
4128+
assert(Pair[P].Dst->getType()->isIntegerTy() && "Dst must be an integer");
41254129
Pair[P].Loops.resize(MaxLevels + 1);
41264130
Pair[P].GroupLoops.resize(MaxLevels + 1);
41274131
Pair[P].Group.resize(Pairs);

0 commit comments

Comments
 (0)