[llvm] 461433f - [DA] Add overflow check when calculating Delta in GCD MIV (#169928)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 1 06:03:57 PST 2025
Author: Ryotaro Kasuga
Date: 2025-12-01T14:03:52Z
New Revision: 461433fea23d18d6a9da73bf09698bd4b3c68ef6
URL: https://github.com/llvm/llvm-project/commit/461433fea23d18d6a9da73bf09698bd4b3c68ef6
DIFF: https://github.com/llvm/llvm-project/commit/461433fea23d18d6a9da73bf09698bd4b3c68ef6.diff
LOG: [DA] Add overflow check when calculating Delta in GCD MIV (#169928)
Add overflow check when computing `Delta` in `gcdMIVtest`.
Fix one of the tests added by #169926.
Added:
Modified:
llvm/lib/Analysis/DependenceAnalysis.cpp
llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 253f4d1441098..c5353a36e4b5d 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -2582,7 +2582,9 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
const SCEV *DstConst = Coefficients;
APInt ExtraGCD = APInt::getZero(BitWidth);
- const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
+ const SCEV *Delta = minusSCEVNoSignedOverflow(DstConst, SrcConst, *SE);
+ if (!Delta)
+ return false;
LLVM_DEBUG(dbgs() << " Delta = " << *Delta << "\n");
const SCEVConstant *Constant = dyn_cast<SCEVConstant>(Delta);
if (const SCEVAddExpr *Sum = dyn_cast<SCEVAddExpr>(Delta)) {
diff --git a/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll b/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll
index 618d14c75faad..76bab98207c79 100644
--- a/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll
+++ b/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll
@@ -89,7 +89,7 @@ define void @gcdmiv_delta_ovfl(ptr %A) {
; CHECK-GCD-MIV-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 0, ptr %idx.0, align 1
; CHECK-GCD-MIV-NEXT: da analyze - consistent output [*]!
; CHECK-GCD-MIV-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.1, align 1
-; CHECK-GCD-MIV-NEXT: da analyze - none!
+; CHECK-GCD-MIV-NEXT: da analyze - consistent output [*|<]!
; CHECK-GCD-MIV-NEXT: Src: store i8 1, ptr %idx.1, align 1 --> Dst: store i8 1, ptr %idx.1, align 1
; CHECK-GCD-MIV-NEXT: da analyze - consistent output [*]!
;
More information about the llvm-commits
mailing list