Skip to content

Commit 10136ad

Browse files
committed
[DA] Remove special handling for SCEVAddExpr in GCD MIV
1 parent 7ace62a commit 10136ad

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

llvm/lib/Analysis/DependenceAnalysis.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,23 +2590,6 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
25902590
const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
25912591
LLVM_DEBUG(dbgs() << " Delta = " << *Delta << "\n");
25922592
const SCEVConstant *Constant = dyn_cast<SCEVConstant>(Delta);
2593-
if (const SCEVAddExpr *Sum = dyn_cast<SCEVAddExpr>(Delta)) {
2594-
// If Delta is a sum of products, we may be able to make further progress.
2595-
for (const SCEV *Operand : Sum->operands()) {
2596-
if (isa<SCEVConstant>(Operand)) {
2597-
assert(!Constant && "Surprised to find multiple constants");
2598-
Constant = cast<SCEVConstant>(Operand);
2599-
} else if (const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Operand)) {
2600-
// Search for constant operand to participate in GCD;
2601-
// If none found; return false.
2602-
std::optional<APInt> ConstOp = getConstanCoefficient(Product);
2603-
if (!ConstOp)
2604-
return false;
2605-
ExtraGCD = APIntOps::GreatestCommonDivisor(ExtraGCD, ConstOp->abs());
2606-
} else
2607-
return false;
2608-
}
2609-
}
26102593
if (!Constant)
26112594
return false;
26122595
APInt ConstDelta = cast<SCEVConstant>(Constant)->getAPInt();

llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ exit:
127127
; A[-3*i - 3*m - INT64_MAX] = 1;
128128
; }
129129
;
130-
; FIXME: DependenceAnalysis currently detects no dependency between the two
131-
; stores, but it may exist. For example, consider `m = 1`. Then,
132-
; `-3*m - INT64_MAX` is `INT64_MAX - 1`. So `-3*i - 3*m - INT64_MAX` is
130+
; Dependency may exist between the two stores. For example, consider `m = 1`.
131+
; Then, `-3*m - INT64_MAX` is `INT64_MAX - 1`. So `-3*i - 3*m - INT64_MAX` is
133132
; effectively `-3*i + (INT64_MAX - 1)`. Thus, accesses will be as follows:
134133
;
135134
; memory access | i == 1 | i == max_i - 1
@@ -143,15 +142,15 @@ define void @gcdmiv_const_ovfl(ptr %A, i64 %m) {
143142
; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1
144143
; CHECK-ALL-NEXT: da analyze - none!
145144
; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
146-
; CHECK-ALL-NEXT: da analyze - none!
145+
; CHECK-ALL-NEXT: da analyze - output [*|<]!
147146
; CHECK-ALL-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
148147
; CHECK-ALL-NEXT: da analyze - none!
149148
;
150149
; CHECK-GCD-MIV-LABEL: 'gcdmiv_const_ovfl'
151150
; CHECK-GCD-MIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1
152151
; CHECK-GCD-MIV-NEXT: da analyze - consistent output [*]!
153152
; CHECK-GCD-MIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
154-
; CHECK-GCD-MIV-NEXT: da analyze - none!
153+
; CHECK-GCD-MIV-NEXT: da analyze - consistent output [*|<]!
155154
; CHECK-GCD-MIV-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
156155
; CHECK-GCD-MIV-NEXT: da analyze - consistent output [*]!
157156
;

0 commit comments

Comments
 (0)