[llvm] 348f4fb - [DA] Add tests that represent edge cases for the Weak Zero SIV tests (NFC) (#183735)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 21:40:22 PST 2026


Author: Ryotaro Kasuga
Date: 2026-03-04T05:40:17Z
New Revision: 348f4fb9e00a4594d8e181803e17071e626fa40c

URL: https://github.com/llvm/llvm-project/commit/348f4fb9e00a4594d8e181803e17071e626fa40c
DIFF: https://github.com/llvm/llvm-project/commit/348f4fb9e00a4594d8e181803e17071e626fa40c.diff

LOG: [DA] Add tests that represent edge cases for the Weak Zero SIV tests (NFC) (#183735)

This patch adds test cases that capture edge cases for the Weak‑Zero SIV
tests. These cases involve loop‑invariant, non‑constant variables, and
special care is required when those variables may be zero.

Added: 
    llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll
    llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_const.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll b/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll
new file mode 100644
index 0000000000000..7468d019e3ee5
--- /dev/null
+++ b/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_coeff.ll
@@ -0,0 +1,106 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -disable-output "-passes=print<da>" 2>&1 \
+; RUN:     | FileCheck %s --check-prefixes=CHECK,CHECK-ALL
+; RUN: opt < %s -disable-output "-passes=print<da>" -da-enable-dependence-test=weak-zero-siv 2>&1 \
+; RUN:     | FileCheck %s --check-prefixes=CHECK,CHECK-WEAK-ZERO-SIV
+
+; for (i = 0; i < 100; i++) {
+;   A[42] = 0;
+;   A[a*i + 42] = 1;
+; }
+;
+; 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:  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:
+; CHECK-ALL-NEXT:    Compare predicate: %a ne) 0
+;
+; CHECK-WEAK-ZERO-SIV-LABEL: 'weak_zero_src_siv_parametric_coeff'
+; 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:  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 [*]!
+;
+entry:
+  br label %loop
+
+loop:
+  %i = phi i64 [ 0, %entry ], [ %i.inc, %loop ]
+  %offset = phi i64 [ 42, %entry ], [ %offset.next, %loop ]
+  %gep.0 = getelementptr inbounds i8, ptr %A, i64 42
+  store i8 0, ptr %gep.0
+  %gep.1 = getelementptr inbounds i8, ptr %A, i64 %offset
+  store i8 1, ptr %gep.1
+  %i.inc = add i64 %i, 1
+  %offset.next = add nuw nsw i64 %offset, %a
+  %ec = icmp eq i64 %i.inc, 100
+  br i1 %ec, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+; for (i = 0; i < 100; i++) {
+;   A[a*i + 42] = 0;
+;   A[42] = 1;
+; }
+;
+; 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
+; CHECK-ALL-NEXT:    da analyze - consistent output [0]!
+; 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:  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]!
+;
+; CHECK-WEAK-ZERO-SIV-LABEL: 'weak_zero_dst_siv_parametric_coeff'
+; 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:  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]!
+;
+entry:
+  br label %loop
+
+loop:
+  %i = phi i64 [ 0, %entry ], [ %i.inc, %loop ]
+  %offset = phi i64 [ 42, %entry ], [ %offset.next, %loop ]
+  %gep.0 = getelementptr inbounds i8, ptr %A, i64 %offset
+  store i8 0, ptr %gep.0
+  %gep.1 = getelementptr inbounds i8, ptr %A, i64 42
+  store i8 1, ptr %gep.1
+  %i.inc = add i64 %i, 1
+  %offset.next = add nuw nsw i64 %offset, %a
+  %ec = icmp eq i64 %i.inc, 100
+  br i1 %ec, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; CHECK: {{.*}}

diff  --git a/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_const.ll b/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_const.ll
new file mode 100644
index 0000000000000..aa58e30a72711
--- /dev/null
+++ b/llvm/test/Analysis/DependenceAnalysis/weak_zero_siv_parametric_const.ll
@@ -0,0 +1,101 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -disable-output "-passes=print<da>" 2>&1 \
+; RUN:     | FileCheck %s --check-prefixes=CHECK,CHECK-ALL
+; RUN: opt < %s -disable-output "-passes=print<da>" -da-enable-dependence-test=weak-zero-siv 2>&1 \
+; RUN:     | FileCheck %s --check-prefixes=CHECK,CHECK-WEAK-ZERO-SIV
+
+; for (i = 0; i < 5; i++) {
+;   A[4*a] = 0;
+;   A[a*i] = 1;
+; }
+;
+; When `a` is zero, the two stores access the same memory location in every
+; iteration.
+;
+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 [*|<]!
+; 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:
+; CHECK-ALL-NEXT:    Compare predicate: %a ne) 0
+;
+; CHECK-WEAK-ZERO-SIV-LABEL: 'weak_zero_src_siv_parametric_coeff'
+; 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 [*|<]!
+; 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 [*]!
+;
+entry:
+  %const = mul nuw nsw i64 %a, 4
+  br label %loop
+
+loop:
+  %i = phi i64 [ 0, %entry ], [ %i.inc, %loop ]
+  %offset = phi i64 [ 0, %entry ], [ %offset.next, %loop ]
+  %gep.0 = getelementptr inbounds i8, ptr %A, i64 %const
+  store i8 0, ptr %gep.0
+  %gep.1 = getelementptr inbounds i8, ptr %A, i64 %offset
+  store i8 1, ptr %gep.1
+  %i.inc = add i64 %i, 1
+  %offset.next = add nuw nsw i64 %offset, %a
+  %ec = icmp eq i64 %i.inc, 5
+  br i1 %ec, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+; for (i = 0; i < 5; i++) {
+;   A[a*i] = 0;
+;   A[4*i] = 1;
+; }
+;
+; When `a` is zero, the two stores access the same memory location in every
+; iteration.
+;
+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
+; CHECK-ALL-NEXT:    da analyze - consistent output [0]!
+; 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 [*|<]!
+; 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]!
+;
+; CHECK-WEAK-ZERO-SIV-LABEL: 'weak_zero_dst_siv_parametric_coeff'
+; 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 [*|<]!
+; 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]!
+;
+entry:
+  %const = mul nuw nsw i64 %a, 4
+  br label %loop
+
+loop:
+  %i = phi i64 [ 0, %entry ], [ %i.inc, %loop ]
+  %offset = phi i64 [ 0, %entry ], [ %offset.next, %loop ]
+  %gep.0 = getelementptr inbounds i8, ptr %A, i64 %offset
+  store i8 0, ptr %gep.0
+  %gep.1 = getelementptr inbounds i8, ptr %A, i64 %const
+  store i8 1, ptr %gep.1
+  %i.inc = add i64 %i, 1
+  %offset.next = add nuw nsw i64 %offset, %a
+  %ec = icmp eq i64 %i.inc, 5
+  br i1 %ec, label %exit, label %loop
+
+exit:
+  ret void
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; CHECK: {{.*}}


        


More information about the llvm-commits mailing list