[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.
This commit is contained in:
Ryotaro Kasuga
2025-12-01 23:03:52 +09:00
committed by GitHub
parent b4c30b0e1e
commit 461433fea2
2 changed files with 4 additions and 2 deletions

View File

@@ -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)) {

View File

@@ -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 [*]!
;