https://github.com/kasuga-fj created https://github.com/llvm/llvm-project/pull/183736
None >From 744ee2dcfd206597bab7eb7a8a6e6e5c931615cf Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <[email protected]> Date: Fri, 27 Feb 2026 11:29:48 +0000 Subject: [PATCH] [DA] Fix the WeakZeroSIV tests when the coeff may be non-zero --- llvm/lib/Analysis/DependenceAnalysis.cpp | 6 ++++-- .../Analysis/DependenceAnalysis/WeakZeroDstSIV.ll | 2 +- .../Analysis/DependenceAnalysis/WeakZeroSrcSIV.ll | 2 +- .../weak_zero_siv_parametric_coeff.ll | 14 ++++---------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp index f2d8abf7aeef4..9ba451ba69a17 100644 --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -1858,7 +1858,8 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff, Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst); LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); - if (SE->isKnownPredicate(CmpInst::ICMP_EQ, SrcConst, DstConst)) { + if (SE->isKnownPredicate(CmpInst::ICMP_EQ, SrcConst, DstConst) && + SE->isKnownNonZero(DstCoeff)) { if (Level < CommonLevels) { Result.DV[Level].Direction &= Dependence::DVEntry::GE; Result.DV[Level].PeelFirst = true; @@ -1971,7 +1972,8 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff, Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); - if (SE->isKnownPredicate(CmpInst::ICMP_EQ, DstConst, SrcConst)) { + if (SE->isKnownPredicate(CmpInst::ICMP_EQ, DstConst, SrcConst) && + SE->isKnownNonZero(SrcCoeff)) { if (Level < CommonLevels) { Result.DV[Level].Direction &= Dependence::DVEntry::LE; Result.DV[Level].PeelFirst = true; diff --git a/llvm/test/Analysis/DependenceAnalysis/WeakZeroDstSIV.ll b/llvm/test/Analysis/DependenceAnalysis/WeakZeroDstSIV.ll index f8a045c425029..f5318b36cca03 100644 --- a/llvm/test/Analysis/DependenceAnalysis/WeakZeroDstSIV.ll +++ b/llvm/test/Analysis/DependenceAnalysis/WeakZeroDstSIV.ll @@ -94,7 +94,7 @@ define void @weakzerodst1(ptr %A, ptr %B, i64 %n) nounwind uwtable ssp { ; CHECK-NEXT: Runtime Assumptions: ; CHECK-NEXT: Compare predicate: (4 * %n) ne) 0 ; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: %0 = load i32, ptr %arrayidx1, align 4 -; CHECK-NEXT: da analyze - flow [p<=|<]! +; CHECK-NEXT: da analyze - flow [*|<]! ; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4 ; CHECK-NEXT: da analyze - confused! ; CHECK-NEXT: Src: %0 = load i32, ptr %arrayidx1, align 4 --> Dst: %0 = load i32, ptr %arrayidx1, align 4 diff --git a/llvm/test/Analysis/DependenceAnalysis/WeakZeroSrcSIV.ll b/llvm/test/Analysis/DependenceAnalysis/WeakZeroSrcSIV.ll index 4ed0abd8d98a9..cf02307f83eb8 100644 --- a/llvm/test/Analysis/DependenceAnalysis/WeakZeroSrcSIV.ll +++ b/llvm/test/Analysis/DependenceAnalysis/WeakZeroSrcSIV.ll @@ -90,7 +90,7 @@ define void @weakzerosrc1(ptr %A, ptr %B, i64 %n) nounwind uwtable ssp { ; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %conv, ptr %arrayidx, align 4 ; CHECK-NEXT: da analyze - consistent output [S]! ; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: %0 = load i32, ptr %arrayidx1, align 4 -; CHECK-NEXT: da analyze - flow [p=>|<]! +; CHECK-NEXT: da analyze - flow [*|<]! ; CHECK-NEXT: Src: store i32 %conv, ptr %arrayidx, align 4 --> Dst: store i32 %0, ptr %B.addr.02, align 4 ; CHECK-NEXT: da analyze - confused! ; CHECK-NEXT: Src: %0 = load i32, ptr %arrayidx1, align 4 --> Dst: %0 = load i32, ptr %arrayidx1, align 4 diff --git a/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll b/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll index 7468d019e3ee5..af23c741e09b2 100644 --- a/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll +++ b/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll @@ -12,15 +12,12 @@ ; When `a` is zero, the two stores access the same memory location in every ; iteration. ; -; FIXME: DependenceAnalysis should yield `*` for the dependency between the two -; stores. -; define void @weak_zero_src_siv_parametric_coeff(ptr %A, i64 %a) { ; CHECK-ALL-LABEL: 'weak_zero_src_siv_parametric_coeff' ; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1 ; CHECK-ALL-NEXT: da analyze - consistent output [S]! ; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 -; CHECK-ALL-NEXT: da analyze - output [p=>|<]! +; CHECK-ALL-NEXT: da analyze - output [*|<]! ; CHECK-ALL-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 ; CHECK-ALL-NEXT: da analyze - consistent output [0]! ; CHECK-ALL-NEXT: Runtime Assumptions: @@ -30,7 +27,7 @@ define void @weak_zero_src_siv_parametric_coeff(ptr %A, i64 %a) { ; CHECK-WEAK-ZERO-SIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1 ; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - consistent output [S]! ; CHECK-WEAK-ZERO-SIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 -; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - output [p=>|<]! +; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - output [*|<]! ; CHECK-WEAK-ZERO-SIV-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 ; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - consistent output [*]! ; @@ -61,9 +58,6 @@ exit: ; When `a` is zero, the two stores access the same memory location in every ; iteration. ; -; FIXME: DependenceAnalysis should yield `*` for the dependency between the two -; stores. -; define void @weak_zero_dst_siv_parametric_coeff(ptr %A, i64 %a) { ; CHECK-ALL-LABEL: 'weak_zero_dst_siv_parametric_coeff' ; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1 @@ -71,7 +65,7 @@ define void @weak_zero_dst_siv_parametric_coeff(ptr %A, i64 %a) { ; CHECK-ALL-NEXT: Runtime Assumptions: ; CHECK-ALL-NEXT: Compare predicate: %a ne) 0 ; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 -; CHECK-ALL-NEXT: da analyze - output [p<=|<]! +; CHECK-ALL-NEXT: da analyze - output [*|<]! ; CHECK-ALL-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 ; CHECK-ALL-NEXT: da analyze - consistent output [S]! ; @@ -79,7 +73,7 @@ define void @weak_zero_dst_siv_parametric_coeff(ptr %A, i64 %a) { ; CHECK-WEAK-ZERO-SIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1 ; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - consistent output [*]! ; CHECK-WEAK-ZERO-SIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 -; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - output [p<=|<]! +; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - output [*|<]! ; CHECK-WEAK-ZERO-SIV-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1 ; CHECK-WEAK-ZERO-SIV-NEXT: da analyze - consistent output [S]! ; _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
