Skip to content

Commit dfb661c

Browse files
committed
[LAA] Add extra tests for #128061.
Extend test coverage for #128061.
1 parent c59c387 commit dfb661c

File tree

3 files changed

+284
-24
lines changed

3 files changed

+284
-24
lines changed

llvm/test/Analysis/LoopAccessAnalysis/early-exit-runtime-checks.ll

Lines changed: 184 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
22
; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s
33

4-
define void @all_exits_dominate_latch_countable_exits_at_most_500_iterations(ptr %A, ptr %B) {
5-
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_500_iterations'
4+
define void @all_exits_dominate_latch_countable_exits_at_most_500_iterations_known_deref(ptr dereferenceable(2000) %A, ptr dereferenceable(2000) %B) {
5+
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_500_iterations_known_deref'
66
; CHECK-NEXT: loop.header:
77
; CHECK-NEXT: Memory dependences are safe with run-time checks
88
; CHECK-NEXT: Dependences:
@@ -14,10 +14,10 @@ define void @all_exits_dominate_latch_countable_exits_at_most_500_iterations(ptr
1414
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
1515
; CHECK-NEXT: Grouped accesses:
1616
; CHECK-NEXT: Group [[GRP1]]:
17-
; CHECK-NEXT: (Low: %B High: (2000 + %B))
17+
; CHECK-NEXT: (Low: %B High: (2000 + %B)<nuw>)
1818
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
1919
; CHECK-NEXT: Group [[GRP2]]:
20-
; CHECK-NEXT: (Low: %A High: (2000 + %A))
20+
; CHECK-NEXT: (Low: %A High: (2000 + %A)<nuw>)
2121
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
2222
; CHECK-EMPTY:
2323
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
@@ -54,15 +54,13 @@ cleanup4:
5454

5555
e.1:
5656
ret void
57+
5758
e.2:
5859
ret void
59-
6060
}
6161

62-
63-
64-
define i32 @all_exits_dominate_latch_countable_exits_at_most_1000_iterations(ptr %A, ptr %B) {
65-
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_1000_iterations'
62+
define void @all_exits_dominate_latch_countable_exits_at_most_500_iterations_not_known_deref(ptr %A, ptr %B) {
63+
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_500_iterations_not_known_deref'
6664
; CHECK-NEXT: loop.header:
6765
; CHECK-NEXT: Memory dependences are safe with run-time checks
6866
; CHECK-NEXT: Dependences:
@@ -74,9 +72,67 @@ define i32 @all_exits_dominate_latch_countable_exits_at_most_1000_iterations(ptr
7472
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
7573
; CHECK-NEXT: Grouped accesses:
7674
; CHECK-NEXT: Group [[GRP3]]:
77-
; CHECK-NEXT: (Low: %B High: (4004 + %B))
75+
; CHECK-NEXT: (Low: %B High: (2000 + %B))
7876
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
7977
; CHECK-NEXT: Group [[GRP4]]:
78+
; CHECK-NEXT: (Low: %A High: (2000 + %A))
79+
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
80+
; CHECK-EMPTY:
81+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
82+
; CHECK-NEXT: SCEV assumptions:
83+
; CHECK-EMPTY:
84+
; CHECK-NEXT: Expressions re-written:
85+
;
86+
entry:
87+
br label %loop.header
88+
89+
loop.header:
90+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
91+
%gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
92+
%gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
93+
%l = load i32, ptr %gep.A, align 4
94+
store i32 0, ptr %gep.B, align 4
95+
%cntable.c.1 = icmp ult i64 %iv, 1000
96+
%iv.next = add nuw nsw i64 %iv, 1
97+
br i1 %cntable.c.1, label %b2, label %e.1
98+
99+
b2:
100+
%uncntable.c.0 = icmp eq i32 %l, 0
101+
br i1 %uncntable.c.0, label %e.2, label %b3
102+
103+
b3:
104+
%cntable.c.2 = icmp eq i64 %iv.next, 500
105+
br i1 %cntable.c.2, label %cleanup4, label %latch
106+
107+
latch:
108+
br label %loop.header
109+
110+
cleanup4:
111+
ret void
112+
113+
e.1:
114+
ret void
115+
116+
e.2:
117+
ret void
118+
}
119+
120+
define i32 @all_exits_dominate_latch_countable_exits_at_most_1000_iterations_known_deref(ptr dereferenceable(4000) %A, ptr dereferenceable(4000) %B) {
121+
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_1000_iterations_known_deref'
122+
; CHECK-NEXT: loop.header:
123+
; CHECK-NEXT: Memory dependences are safe with run-time checks
124+
; CHECK-NEXT: Dependences:
125+
; CHECK-NEXT: Run-time memory checks:
126+
; CHECK-NEXT: Check 0:
127+
; CHECK-NEXT: Comparing group ([[GRP5:0x[0-9a-f]+]]):
128+
; CHECK-NEXT: %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
129+
; CHECK-NEXT: Against group ([[GRP6:0x[0-9a-f]+]]):
130+
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
131+
; CHECK-NEXT: Grouped accesses:
132+
; CHECK-NEXT: Group [[GRP5]]:
133+
; CHECK-NEXT: (Low: %B High: (4004 + %B))
134+
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
135+
; CHECK-NEXT: Group [[GRP6]]:
80136
; CHECK-NEXT: (Low: %A High: (4004 + %A))
81137
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
82138
; CHECK-EMPTY:
@@ -119,6 +175,63 @@ e.2:
119175
ret i32 2
120176
}
121177

178+
define i32 @all_exits_dominate_latch_countable_exits_at_most_1000_iterations_not_known_deref(ptr %A, ptr %B) {
179+
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_1000_iterations_not_known_deref'
180+
; CHECK-NEXT: loop.header:
181+
; CHECK-NEXT: Memory dependences are safe with run-time checks
182+
; CHECK-NEXT: Dependences:
183+
; CHECK-NEXT: Run-time memory checks:
184+
; CHECK-NEXT: Check 0:
185+
; CHECK-NEXT: Comparing group ([[GRP7:0x[0-9a-f]+]]):
186+
; CHECK-NEXT: %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
187+
; CHECK-NEXT: Against group ([[GRP8:0x[0-9a-f]+]]):
188+
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
189+
; CHECK-NEXT: Grouped accesses:
190+
; CHECK-NEXT: Group [[GRP7]]:
191+
; CHECK-NEXT: (Low: %B High: (4004 + %B))
192+
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
193+
; CHECK-NEXT: Group [[GRP8]]:
194+
; CHECK-NEXT: (Low: %A High: (4004 + %A))
195+
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
196+
; CHECK-EMPTY:
197+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
198+
; CHECK-NEXT: SCEV assumptions:
199+
; CHECK-EMPTY:
200+
; CHECK-NEXT: Expressions re-written:
201+
;
202+
entry:
203+
br label %loop.header
204+
205+
loop.header:
206+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
207+
%gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
208+
%gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
209+
%l = load i32, ptr %gep.A, align 4
210+
store i32 0, ptr %gep.B, align 4
211+
%cntable.c.1 = icmp ult i64 %iv, 1000
212+
br i1 %cntable.c.1, label %b2, label %e.1
213+
214+
b2:
215+
%uncntable.c.0 = icmp eq i32 %l, 0
216+
br i1 %uncntable.c.0, label %e.2, label %b3
217+
218+
b3:
219+
%iv.next = add nuw nsw i64 %iv, 1
220+
%cntable.c.2 = icmp eq i64 %iv.next, 2000
221+
br i1 %cntable.c.2, label %e.0, label %latch
222+
223+
latch:
224+
br label %loop.header
225+
226+
e.0:
227+
ret i32 0
228+
229+
e.1:
230+
ret i32 1
231+
232+
e.2:
233+
ret i32 2
234+
}
122235

123236
define i32 @not_all_exits_dominate_latch(ptr %A, ptr %B) {
124237
; CHECK-LABEL: 'not_all_exits_dominate_latch'
@@ -164,22 +277,77 @@ e.2:
164277
ret i32 1
165278
}
166279

167-
define i32 @b3_does_not_dominate_latch(ptr %A, ptr %B) {
168-
; CHECK-LABEL: 'b3_does_not_dominate_latch'
280+
define i32 @b3_does_not_dominate_latch_known_deref(ptr dereferenceable(4000) %A, ptr dereferenceable(4000) %B) {
281+
; CHECK-LABEL: 'b3_does_not_dominate_latch_known_deref'
169282
; CHECK-NEXT: loop.header:
170283
; CHECK-NEXT: Memory dependences are safe with run-time checks
171284
; CHECK-NEXT: Dependences:
172285
; CHECK-NEXT: Run-time memory checks:
173286
; CHECK-NEXT: Check 0:
174-
; CHECK-NEXT: Comparing group ([[GRP5:0x[0-9a-f]+]]):
287+
; CHECK-NEXT: Comparing group ([[GRP9:0x[0-9a-f]+]]):
175288
; CHECK-NEXT: %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
176-
; CHECK-NEXT: Against group ([[GRP6:0x[0-9a-f]+]]):
289+
; CHECK-NEXT: Against group ([[GRP10:0x[0-9a-f]+]]):
177290
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
178291
; CHECK-NEXT: Grouped accesses:
179-
; CHECK-NEXT: Group [[GRP5]]:
292+
; CHECK-NEXT: Group [[GRP9]]:
180293
; CHECK-NEXT: (Low: %B High: (4004 + %B))
181294
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
182-
; CHECK-NEXT: Group [[GRP6]]:
295+
; CHECK-NEXT: Group [[GRP10]]:
296+
; CHECK-NEXT: (Low: %A High: (4004 + %A))
297+
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
298+
; CHECK-EMPTY:
299+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
300+
; CHECK-NEXT: SCEV assumptions:
301+
; CHECK-EMPTY:
302+
; CHECK-NEXT: Expressions re-written:
303+
;
304+
entry:
305+
br label %loop.header
306+
307+
loop.header:
308+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
309+
%gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
310+
%gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
311+
%l = load i32, ptr %gep.A, align 4
312+
store i32 0, ptr %gep.B, align 4
313+
%cntable.c.1 = icmp ult i64 %iv, 1000
314+
%iv.next = add nuw nsw i64 %iv, 1
315+
br i1 %cntable.c.1, label %b2, label %e.1
316+
317+
b2:
318+
%uncntable.c.0 = icmp eq i32 %l, 0
319+
br i1 %uncntable.c.0, label %latch, label %b3
320+
321+
b3:
322+
%cntable.c.2 = icmp eq i64 %iv.next, 500
323+
br i1 %cntable.c.2, label %e.0, label %latch
324+
325+
latch:
326+
br label %loop.header
327+
328+
e.0:
329+
ret i32 0
330+
331+
e.1:
332+
ret i32 1
333+
}
334+
335+
define i32 @b3_does_not_dominate_latch_not_known_deref(ptr %A, ptr %B) {
336+
; CHECK-LABEL: 'b3_does_not_dominate_latch_not_known_deref'
337+
; CHECK-NEXT: loop.header:
338+
; CHECK-NEXT: Memory dependences are safe with run-time checks
339+
; CHECK-NEXT: Dependences:
340+
; CHECK-NEXT: Run-time memory checks:
341+
; CHECK-NEXT: Check 0:
342+
; CHECK-NEXT: Comparing group ([[GRP11:0x[0-9a-f]+]]):
343+
; CHECK-NEXT: %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
344+
; CHECK-NEXT: Against group ([[GRP12:0x[0-9a-f]+]]):
345+
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
346+
; CHECK-NEXT: Grouped accesses:
347+
; CHECK-NEXT: Group [[GRP11]]:
348+
; CHECK-NEXT: (Low: %B High: (4004 + %B))
349+
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
350+
; CHECK-NEXT: Group [[GRP12]]:
183351
; CHECK-NEXT: (Low: %A High: (4004 + %A))
184352
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
185353
; CHECK-EMPTY:

llvm/test/Analysis/LoopAccessAnalysis/evaluate-at-symbolic-max-backedge-taken-count-may-wrap.ll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,46 @@ exit:
136136
%res = phi i32 [ %iv.next, %loop.latch ]
137137
ret i32 %res
138138
}
139+
140+
; FIXME: evaluating at symbolic max BTC wraps around to a positive
141+
; offset: (2 + (2 * %y) + %P)
142+
define void @runtime_check_with_symbolic_max_wraps_to_positive_offset(ptr %P, ptr %S, i32 %x, i32 %y) {
143+
; CHECK-LABEL: 'runtime_check_with_symbolic_max_wraps_to_positive_offset'
144+
; CHECK-NEXT: loop:
145+
; CHECK-NEXT: Memory dependences are safe with run-time checks
146+
; CHECK-NEXT: Dependences:
147+
; CHECK-NEXT: Run-time memory checks:
148+
; CHECK-NEXT: Check 0:
149+
; CHECK-NEXT: Comparing group ([[GRP5:0x[0-9a-f]+]]):
150+
; CHECK-NEXT: %gep.iv = getelementptr inbounds i16, ptr %P, i32 %iv
151+
; CHECK-NEXT: Against group ([[GRP6:0x[0-9a-f]+]]):
152+
; CHECK-NEXT: ptr %S
153+
; CHECK-NEXT: Grouped accesses:
154+
; CHECK-NEXT: Group [[GRP5]]:
155+
; CHECK-NEXT: (Low: ((2 * %y) + %P) High: (2 + (2 * %y) + %P))
156+
; CHECK-NEXT: Member: {((2 * %y) + %P),+,2}<%loop>
157+
; CHECK-NEXT: Group [[GRP6]]:
158+
; CHECK-NEXT: (Low: %S High: (4 + %S))
159+
; CHECK-NEXT: Member: %S
160+
; CHECK-EMPTY:
161+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
162+
; CHECK-NEXT: SCEV assumptions:
163+
; CHECK-EMPTY:
164+
; CHECK-NEXT: Expressions re-written:
165+
;
166+
entry:
167+
br label %loop
168+
169+
loop:
170+
%iv = phi i32 [ %y, %entry ], [ %iv.next, %loop ]
171+
%gep.iv = getelementptr inbounds i16 , ptr %P, i32 %iv
172+
%l = load i32, ptr %S
173+
store i16 0, ptr %gep.iv, align 4
174+
%iv.next = add nsw i32 %iv, 1
175+
%a = and i32 %l, 2147483648
176+
%c.2 = icmp slt i32 %iv.next, %a
177+
br i1 %c.2, label %loop, label %exit
178+
179+
exit:
180+
ret void
181+
}

0 commit comments

Comments
 (0)