[llvm] [DA] Add test where inferDomainOfAffine causes overflow (PR #171990)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 03:19:28 PST 2025
https://github.com/kasuga-fj created https://github.com/llvm/llvm-project/pull/171990
None
>From c7bb16223b20ecbc3c0d703982e9d2843b91ea41 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Thu, 11 Dec 2025 13:21:54 +0000
Subject: [PATCH] [DA] Add test where inferDomainOfAffine causes overflow
---
.../infer_affine_domain_ovlf.ll | 65 +++++++++++++++++++
1 file changed, 65 insertions(+)
create mode 100644 llvm/test/Analysis/DependenceAnalysis/infer_affine_domain_ovlf.ll
diff --git a/llvm/test/Analysis/DependenceAnalysis/infer_affine_domain_ovlf.ll b/llvm/test/Analysis/DependenceAnalysis/infer_affine_domain_ovlf.ll
new file mode 100644
index 0000000000000..21fe1ef71d9df
--- /dev/null
+++ b/llvm/test/Analysis/DependenceAnalysis/infer_affine_domain_ovlf.ll
@@ -0,0 +1,65 @@
+; 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=exact-siv 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-EXACT-SIV
+
+; offset = INT64_MIN;
+; for (i = 0; i < 5; i++, offset += (1LL << 61)) {
+; A[i] = 0;
+; if (0 <= offset)
+; A[offset] = 1;
+; }
+;
+; FIXME: DependenceAnalysis curently fails to detect a dependency between the
+; two stores.
+;
+; memory access | i == 0 | i == 4
+; ------------------|--------|---------
+; A[i] | A[0] |
+; A[2^61*i - 2^63] | | A[0]
+
+define void @infer_affine_domain_ovfl(ptr %A) {
+; CHECK-ALL-LABEL: 'infer_affine_domain_ovfl'
+; 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 - none!
+; 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 - none!
+; 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 - none!
+;
+; CHECK-EXACT-SIV-LABEL: 'infer_affine_domain_ovfl'
+; CHECK-EXACT-SIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1
+; CHECK-EXACT-SIV-NEXT: da analyze - consistent output [*]!
+; CHECK-EXACT-SIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
+; CHECK-EXACT-SIV-NEXT: da analyze - none!
+; CHECK-EXACT-SIV-NEXT: Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
+; CHECK-EXACT-SIV-NEXT: da analyze - consistent output [*]!
+;
+entry:
+ br label %loop.header
+
+loop.header:
+ %i = phi i64 [ 0, %entry ], [ %i.inc, %loop.latch ]
+ %offset = phi i64 [ -9223372036854775808, %entry ], [ %offset.next, %loop.latch ]
+ %gep.0 = getelementptr i8, ptr %A, i64 %i
+ store i8 0, ptr %gep.0
+ %cond = icmp sge i64 %offset, 0
+ br i1 %cond, label %if.then, label %loop.latch
+
+if.then:
+ %gep.1 = getelementptr i8, ptr %A, i64 %offset
+ store i8 1, ptr %gep.1
+ br label %loop.latch
+
+loop.latch:
+ %i.inc = add i64 %i, 1
+ %offset.next = add nsw i64 %offset, 2305843009213693952
+ %ec = icmp eq i64 %i.inc, 5
+ br i1 %ec, label %exit, label %loop.header
+
+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