Skip to content

Commit 2babcd0

Browse files
fhahnAnthony Tran
authored andcommitted
[LAA] Update early-exit test to cover last valid & first invalid access.
Make sure tests cover loops accessing the last valid and the first invalid memory location. Note that the test `@all_exits_dominate_latch_countable_exits_at_most_1000_iterations_kno` has been modified to execute at most 1000 iterations; it previously executed 1001 iterations.
1 parent 105b1b0 commit 2babcd0

File tree

1 file changed

+120
-3
lines changed

1 file changed

+120
-3
lines changed

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

Lines changed: 120 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,65 @@ e.2:
5959
ret void
6060
}
6161

62+
define void @all_exits_dominate_latch_countable_exits_at_most_501_iterations_known_deref(ptr dereferenceable(2000) %A, ptr dereferenceable(2000) %B) {
63+
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_501_iterations_known_deref'
64+
; CHECK-NEXT: loop.header:
65+
; CHECK-NEXT: Memory dependences are safe with run-time checks
66+
; CHECK-NEXT: Dependences:
67+
; CHECK-NEXT: Run-time memory checks:
68+
; CHECK-NEXT: Check 0:
69+
; CHECK-NEXT: Comparing group GRP0:
70+
; CHECK-NEXT: %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
71+
; CHECK-NEXT: Against group GRP1:
72+
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
73+
; CHECK-NEXT: Grouped accesses:
74+
; CHECK-NEXT: Group GRP0:
75+
; CHECK-NEXT: (Low: %B High: (2004 + %B))
76+
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
77+
; CHECK-NEXT: Group GRP1:
78+
; CHECK-NEXT: (Low: %A High: (2004 + %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, 501
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+
62121
define void @all_exits_dominate_latch_countable_exits_at_most_500_iterations_not_known_deref(ptr %A, ptr %B) {
63122
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_500_iterations_not_known_deref'
64123
; CHECK-NEXT: loop.header:
@@ -130,6 +189,64 @@ define i32 @all_exits_dominate_latch_countable_exits_at_most_1000_iterations_kno
130189
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
131190
; CHECK-NEXT: Grouped accesses:
132191
; CHECK-NEXT: Group GRP0:
192+
; CHECK-NEXT: (Low: %B High: (4000 + %B)<nuw>)
193+
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
194+
; CHECK-NEXT: Group GRP1:
195+
; CHECK-NEXT: (Low: %A High: (4000 + %A)<nuw>)
196+
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
197+
; CHECK-EMPTY:
198+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
199+
; CHECK-NEXT: SCEV assumptions:
200+
; CHECK-EMPTY:
201+
; CHECK-NEXT: Expressions re-written:
202+
;
203+
entry:
204+
br label %loop.header
205+
206+
loop.header:
207+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
208+
%gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
209+
%gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
210+
%l = load i32, ptr %gep.A, align 4
211+
store i32 0, ptr %gep.B, align 4
212+
%cntable.c.1 = icmp ult i64 %iv, 999
213+
br i1 %cntable.c.1, label %b2, label %e.1
214+
215+
b2:
216+
%uncntable.c.0 = icmp eq i32 %l, 0
217+
br i1 %uncntable.c.0, label %e.2, label %b3
218+
219+
b3:
220+
%iv.next = add nuw nsw i64 %iv, 1
221+
%cntable.c.2 = icmp eq i64 %iv.next, 2000
222+
br i1 %cntable.c.2, label %e.0, label %latch
223+
224+
latch:
225+
br label %loop.header
226+
227+
e.0:
228+
ret i32 0
229+
230+
e.1:
231+
ret i32 1
232+
233+
e.2:
234+
ret i32 2
235+
}
236+
237+
define i32 @all_exits_dominate_latch_countable_exits_at_most_1001_iterations_known_deref(ptr dereferenceable(4000) %A, ptr dereferenceable(4000) %B) {
238+
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_1001_iterations_known_deref'
239+
; CHECK-NEXT: loop.header:
240+
; CHECK-NEXT: Memory dependences are safe with run-time checks
241+
; CHECK-NEXT: Dependences:
242+
; CHECK-NEXT: Run-time memory checks:
243+
; CHECK-NEXT: Check 0:
244+
; CHECK-NEXT: Comparing group GRP0:
245+
; CHECK-NEXT: %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
246+
; CHECK-NEXT: Against group GRP1:
247+
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
248+
; CHECK-NEXT: Grouped accesses:
249+
; CHECK-NEXT: Group GRP0:
133250
; CHECK-NEXT: (Low: %B High: (4004 + %B))
134251
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
135252
; CHECK-NEXT: Group GRP1:
@@ -188,10 +305,10 @@ define i32 @all_exits_dominate_latch_countable_exits_at_most_1000_iterations_not
188305
; CHECK-NEXT: %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
189306
; CHECK-NEXT: Grouped accesses:
190307
; CHECK-NEXT: Group GRP0:
191-
; CHECK-NEXT: (Low: %B High: (4004 + %B))
308+
; CHECK-NEXT: (Low: %B High: (4000 + %B))
192309
; CHECK-NEXT: Member: {%B,+,4}<nuw><%loop.header>
193310
; CHECK-NEXT: Group GRP1:
194-
; CHECK-NEXT: (Low: %A High: (4004 + %A))
311+
; CHECK-NEXT: (Low: %A High: (4000 + %A))
195312
; CHECK-NEXT: Member: {%A,+,4}<nuw><%loop.header>
196313
; CHECK-EMPTY:
197314
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
@@ -208,7 +325,7 @@ loop.header:
208325
%gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
209326
%l = load i32, ptr %gep.A, align 4
210327
store i32 0, ptr %gep.B, align 4
211-
%cntable.c.1 = icmp ult i64 %iv, 1000
328+
%cntable.c.1 = icmp ult i64 %iv, 999
212329
br i1 %cntable.c.1, label %b2, label %e.1
213330

214331
b2:

0 commit comments

Comments
 (0)