Skip to content

Commit a4f8705

Browse files
committed
[LAA] Precommit test with loops where indices are loaded in each iter.
Add tests which are not safe to vectorize because %indices are loaded in the loop and the same indices could be loaded in later iterations. Tests for #87189.
1 parent f4254f3 commit a4f8705

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s
3+
4+
; Test case for https://github.com/llvm/llvm-project/issues/87189.
5+
; It is not safe to vectorize because %indices are loaded in the loop and the
6+
; same indices could be loaded in later iterations.
7+
; FIXME: currently this is incorrectly considered safe for vectorization with
8+
; runtime checks
9+
define void @B_indices_loaded_in_loop_A_stored(ptr %A, ptr noalias %B, i64 %N) {
10+
; CHECK-LABEL: 'B_indices_loaded_in_loop_A_stored'
11+
; CHECK-NEXT: loop:
12+
; CHECK-NEXT: Memory dependences are safe with run-time checks
13+
; CHECK-NEXT: Dependences:
14+
; CHECK-NEXT: Run-time memory checks:
15+
; CHECK-NEXT: Check 0:
16+
; CHECK-NEXT: Comparing group ([[GRP1:0x[0-9a-f]+]]):
17+
; CHECK-NEXT: %gep.A.1 = getelementptr inbounds i32, ptr %A, i64 %iv
18+
; CHECK-NEXT: Against group ([[GRP2:0x[0-9a-f]+]]):
19+
; CHECK-NEXT: %gep.A.0 = getelementptr inbounds i8, ptr %A, i64 %iv
20+
; CHECK-NEXT: Grouped accesses:
21+
; CHECK-NEXT: Group [[GRP1]]:
22+
; CHECK-NEXT: (Low: %A High: ((4 * %N) + %A))
23+
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop>
24+
; CHECK-NEXT: Group [[GRP2]]:
25+
; CHECK-NEXT: (Low: %A High: (%N + %A))
26+
; CHECK-NEXT: Member: {%A,+,1}<nuw><%loop>
27+
; CHECK-EMPTY:
28+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
29+
; CHECK-NEXT: SCEV assumptions:
30+
; CHECK-EMPTY:
31+
; CHECK-NEXT: Expressions re-written:
32+
;
33+
entry:
34+
br label %loop
35+
36+
loop:
37+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
38+
%gep.A.0 = getelementptr inbounds i8, ptr %A, i64 %iv
39+
%indices = load i8, ptr %gep.A.0, align 1
40+
%indices.ext = zext i8 %indices to i64
41+
%gep.B = getelementptr inbounds i32, ptr %B, i64 %indices.ext
42+
%l = load i32, ptr %gep.B, align 4
43+
%inc = add i32 %l, 1
44+
store i32 %inc, ptr %gep.B, align 4
45+
%gep.A.1 = getelementptr inbounds i32, ptr %A, i64 %iv
46+
store i32 %l, ptr %gep.A.1, align 4
47+
%iv.next = add nuw nsw i64 %iv, 1
48+
%ec = icmp eq i64 %iv.next, %N
49+
br i1 %ec, label %exit, label %loop
50+
51+
exit:
52+
ret void
53+
}
54+
55+
; It is not safe to vectorize because %indices are loaded in the loop and the
56+
; same indices could be loaded in later iterations.
57+
define void @B_indices_loaded_in_loop_A_not_stored(ptr %A, ptr noalias %B, i64 %N) {
58+
; CHECK-LABEL: 'B_indices_loaded_in_loop_A_not_stored'
59+
; CHECK-NEXT: loop:
60+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
61+
; CHECK-NEXT: Unknown data dependence.
62+
; CHECK-NEXT: Dependences:
63+
; CHECK-NEXT: Unknown:
64+
; CHECK-NEXT: %l = load i32, ptr %gep.B, align 4 ->
65+
; CHECK-NEXT: store i32 %inc, ptr %gep.B, align 4
66+
; CHECK-EMPTY:
67+
; CHECK-NEXT: Run-time memory checks:
68+
; CHECK-NEXT: Grouped accesses:
69+
; CHECK-EMPTY:
70+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
71+
; CHECK-NEXT: SCEV assumptions:
72+
; CHECK-EMPTY:
73+
; CHECK-NEXT: Expressions re-written:
74+
;
75+
entry:
76+
br label %loop
77+
78+
loop:
79+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
80+
%gep.A.0 = getelementptr inbounds i8, ptr %A, i64 %iv
81+
%indices = load i8, ptr %gep.A.0, align 1
82+
%indices.ext = zext i8 %indices to i64
83+
%gep.B = getelementptr inbounds i32, ptr %B, i64 %indices.ext
84+
%l = load i32, ptr %gep.B, align 4
85+
%inc = add i32 %l, 1
86+
store i32 %inc, ptr %gep.B, align 4
87+
%iv.next = add nuw nsw i64 %iv, 1
88+
%ec = icmp eq i64 %iv.next, %N
89+
br i1 %ec, label %exit, label %loop
90+
91+
exit:
92+
ret void
93+
}

0 commit comments

Comments
 (0)