File: early-exit-runtime-checks.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (220 lines) | stat: -rw-r--r-- 6,845 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s

define void @all_exits_dominate_latch_countable_exits_at_most_500_iterations(ptr %A, ptr %B) {
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_500_iterations'
; CHECK-NEXT:    loop.header:
; CHECK-NEXT:      Memory dependences are safe with run-time checks
; CHECK-NEXT:      Dependences:
; CHECK-NEXT:      Run-time memory checks:
; CHECK-NEXT:      Check 0:
; CHECK-NEXT:        Comparing group ([[GRP1:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
; CHECK-NEXT:        Against group ([[GRP2:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
; CHECK-NEXT:      Grouped accesses:
; CHECK-NEXT:        Group [[GRP1]]:
; CHECK-NEXT:          (Low: %B High: (2000 + %B))
; CHECK-NEXT:            Member: {%B,+,4}<nuw><%loop.header>
; CHECK-NEXT:        Group [[GRP2]]:
; CHECK-NEXT:          (Low: %A High: (2000 + %A))
; CHECK-NEXT:            Member: {%A,+,4}<nuw><%loop.header>
; CHECK-EMPTY:
; CHECK-NEXT:      Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT:      SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT:      Expressions re-written:
;
entry:
  br label %loop.header

loop.header:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
  %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
  %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
  %l = load i32, ptr %gep.A, align 4
  store i32 0, ptr %gep.B, align 4
  %cntable.c.1 = icmp ult i64 %iv, 1000
  %iv.next = add nuw nsw i64 %iv, 1
  br i1 %cntable.c.1, label %b2, label %e.1

b2:
  %uncntable.c.0 = icmp eq i32 %l, 0
  br i1 %uncntable.c.0, label %e.2, label %b3

b3:
  %cntable.c.2 = icmp eq i64 %iv.next, 500
  br i1 %cntable.c.2, label %cleanup4, label %latch

latch:
  br label %loop.header

cleanup4:
  ret void

e.1:
  ret void
e.2:
  ret void

}



define i32 @all_exits_dominate_latch_countable_exits_at_most_1000_iterations(ptr %A, ptr %B) {
; CHECK-LABEL: 'all_exits_dominate_latch_countable_exits_at_most_1000_iterations'
; CHECK-NEXT:    loop.header:
; CHECK-NEXT:      Memory dependences are safe with run-time checks
; CHECK-NEXT:      Dependences:
; CHECK-NEXT:      Run-time memory checks:
; CHECK-NEXT:      Check 0:
; CHECK-NEXT:        Comparing group ([[GRP3:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
; CHECK-NEXT:        Against group ([[GRP4:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
; CHECK-NEXT:      Grouped accesses:
; CHECK-NEXT:        Group [[GRP3]]:
; CHECK-NEXT:          (Low: %B High: (4004 + %B))
; CHECK-NEXT:            Member: {%B,+,4}<nuw><%loop.header>
; CHECK-NEXT:        Group [[GRP4]]:
; CHECK-NEXT:          (Low: %A High: (4004 + %A))
; CHECK-NEXT:            Member: {%A,+,4}<nuw><%loop.header>
; CHECK-EMPTY:
; CHECK-NEXT:      Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT:      SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT:      Expressions re-written:
;
entry:
  br label %loop.header

loop.header:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
  %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
  %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
  %l = load i32, ptr %gep.A, align 4
  store i32 0, ptr %gep.B, align 4
  %cntable.c.1 = icmp ult i64 %iv, 1000
  br i1 %cntable.c.1, label %b2, label %e.1

b2:
  %uncntable.c.0 = icmp eq i32 %l, 0
  br i1 %uncntable.c.0, label %e.2, label %b3

b3:
  %iv.next = add nuw nsw i64 %iv, 1
  %cntable.c.2 = icmp eq i64 %iv.next, 2000
  br i1 %cntable.c.2, label %e.0, label %latch

latch:
  br label %loop.header

e.0:
  ret i32 0

e.1:
  ret i32 1

e.2:
  ret i32 2
}


define i32 @not_all_exits_dominate_latch(ptr %A, ptr %B) {
; CHECK-LABEL: 'not_all_exits_dominate_latch'
; CHECK-NEXT:    loop.header:
; CHECK-NEXT:      Report: could not determine number of loop iterations
; CHECK-NEXT:      Dependences:
; CHECK-NEXT:      Run-time memory checks:
; CHECK-NEXT:      Grouped accesses:
; CHECK-EMPTY:
; CHECK-NEXT:      Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT:      SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT:      Expressions re-written:
;
entry:
  br label %loop.header

loop.header:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
  %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
  %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
  %l = load i32, ptr %gep.A, align 4
  store i32 0, ptr %gep.B, align 4
  %cntable.c.1 = icmp ult i64 %iv, 1000
  %iv.next = add nuw nsw i64 %iv, 1
  br i1 %cntable.c.1, label %b2, label %latch

b2:
  %uncntable.c.0 = icmp eq i32 %l, 0
  br i1 %uncntable.c.0, label %e.2, label %b3

b3:
  %cntable.c.2 = icmp eq i64 %iv.next, 2000
  br i1 %cntable.c.2, label %e.0, label %latch

latch:
  br label %loop.header

e.0:
  ret i32 0

e.2:
  ret i32 1
}

define i32 @b3_does_not_dominate_latch(ptr %A, ptr %B) {
; CHECK-LABEL: 'b3_does_not_dominate_latch'
; CHECK-NEXT:    loop.header:
; CHECK-NEXT:      Memory dependences are safe with run-time checks
; CHECK-NEXT:      Dependences:
; CHECK-NEXT:      Run-time memory checks:
; CHECK-NEXT:      Check 0:
; CHECK-NEXT:        Comparing group ([[GRP5:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
; CHECK-NEXT:        Against group ([[GRP6:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
; CHECK-NEXT:      Grouped accesses:
; CHECK-NEXT:        Group [[GRP5]]:
; CHECK-NEXT:          (Low: %B High: (4004 + %B))
; CHECK-NEXT:            Member: {%B,+,4}<nuw><%loop.header>
; CHECK-NEXT:        Group [[GRP6]]:
; CHECK-NEXT:          (Low: %A High: (4004 + %A))
; CHECK-NEXT:            Member: {%A,+,4}<nuw><%loop.header>
; CHECK-EMPTY:
; CHECK-NEXT:      Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT:      SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT:      Expressions re-written:
;
entry:
  br label %loop.header

loop.header:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
  %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
  %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
  %l = load i32, ptr %gep.A, align 4
  store i32 0, ptr %gep.B, align 4
  %cntable.c.1 = icmp ult i64 %iv, 1000
  %iv.next = add nuw nsw i64 %iv, 1
  br i1 %cntable.c.1, label %b2, label %e.1

b2:
  %uncntable.c.0 = icmp eq i32 %l, 0
  br i1 %uncntable.c.0, label %latch, label %b3

b3:
  %cntable.c.2 = icmp eq i64 %iv.next, 500
  br i1 %cntable.c.2, label %e.0, label %latch

latch:
  br label %loop.header

e.0:
  ret i32 0

e.1:
  ret i32 1
}