[llvm] [DA] Add tests where dependencies are missed due to overflow (NFC) (PR #164246)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 28 08:15:51 PDT 2025
================
@@ -0,0 +1,63 @@
+; 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 | FileCheck %s
+; RUN: opt < %s -disable-output "-passes=print<da>" -da-enable-dependence-test=gcd-miv 2>&1 \
+; RUN: | FileCheck %s --check-prefix=CHECK-GCD-MIV
+
+; offset0 = 4;
+; offset1 = 0;
+; for (i = 0; i < 100; i++) {
+; A[offset0] = 1;
+; A[offset1] = 2;
+; offset0 += 3*m;
+; offset1 += 3;
+; }
+;
+; FIXME: DependenceAnalysis currently detects no dependency between the two
+; stores, but it does exist. E.g., consider `m` is 12297829382473034411, which
+; is a modular multiplicative inverse of 3 under modulo 2^64. Then `offset0` is
+; effectively `i + 4`, so accesses will be as follows:
+;
+; - A[offset0] : A[4], A[5], A[6], ...
+; - A[offset1] : A[0], A[3], A[6], ...
+;
+; The root cause is that DA assumes `3*m` begin a multiple of 3 in mathematical
+; sense, which isn't necessarily true due to overflow.
+;
+define void @gcdmiv_coef_ovfl(ptr %A, i64 %m) {
----------------
Meinersbur wrote:
`3*m` is loop-invariant, and even computed before the loop. Ideally, DA shouldn't care about overflow, it us just "some invariant value" with this same result of `%step` was passed directly as argument instead if `%m`.
https://github.com/llvm/llvm-project/pull/164246
More information about the llvm-commits
mailing list