[llvm] [Delinearization] Precommit test. NFC. (PR #175173)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 9 06:17:51 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Sjoerd Meijer (sjoerdmeijer)
<details>
<summary>Changes</summary>
This precommits a test for #<!-- -->175158 which should demonstrate that Delinearization succeeds when we extract loop bounds from the global variable definition.
---
Full diff: https://github.com/llvm/llvm-project/pull/175173.diff
1 Files Affected:
- (added) llvm/test/Analysis/Delinearization/global_array_bounds.ll (+52)
``````````diff
diff --git a/llvm/test/Analysis/Delinearization/global_array_bounds.ll b/llvm/test/Analysis/Delinearization/global_array_bounds.ll
new file mode 100644
index 0000000000000..1e77dff90b86d
--- /dev/null
+++ b/llvm/test/Analysis/Delinearization/global_array_bounds.ll
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes='print<delinearization>' -disable-output 2>&1 | FileCheck %s
+
+; Pseudo-code:
+;
+; arr[10][20];
+;
+; for i=0 to 10
+; for j=0 to 20
+; a[i][j]; // arr + i*20 + j
+;
+
+ at test_array_10x20 = global [10 x [20 x i32]] zeroinitializer
+
+; Function that accesses a 2D array with dimensions [10][20].
+define void @test_2d_array(i64 %i, i64 %j) {
+; CHECK-LABEL: 'test_2d_array'
+; CHECK-NEXT: Inst: %val = load i32, ptr %ptr, align 4
+; CHECK-NEXT: AccessFunction: {{\{\{}}0,+,80}<nuw><nsw><%for.i>,+,4}<%for.j>
+; CHECK-NEXT: failed to delinearize
+;
+entry:
+ %arr = getelementptr inbounds [10 x [20 x i32]], ptr @test_array_10x20, i32 0, i32 0
+ br label %for.i
+
+for.i:
+ %i.cur = phi i64 [ 0, %entry ], [ %i.next, %for.j.end ]
+ %i.cmp = icmp slt i64 %i.cur, 10
+ br i1 %i.cmp, label %for.j, label %exit
+
+for.j:
+ %j.cur = phi i64 [ 0, %for.i ], [ %j.next, %for.j ]
+
+ ; Compute linear access: arr[i][j] = arr + i*20 + j
+ %i.mul = mul i64 %i.cur, 20
+ %idx = add i64 %i.mul, %j.cur
+ %ptr = getelementptr inbounds i32, ptr %arr, i64 %idx
+
+ ; Load from the computed address
+ %val = load i32, ptr %ptr, align 4
+
+ %j.next = add i64 %j.cur, 1
+ %j.cmp = icmp slt i64 %j.next, 20
+ br i1 %j.cmp, label %for.j, label %for.j.end
+
+for.j.end:
+ %i.next = add i64 %i.cur, 1
+ br label %for.i
+
+exit:
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/175173
More information about the llvm-commits
mailing list