load-store-range.ll
7.38 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -ipsccp -S | FileCheck %s
declare void @use(i1)
@G = internal global i32 0
define void @test1a() {
; CHECK-LABEL: @test1a(
; CHECK-NEXT: [[X:%.*]] = load i32, i32* @G
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_1:%.*]] = icmp eq i32 [[X]], 20
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: ret void
;
%X = load i32, i32* @G
%t.1 = icmp ne i32 %X, 124
call void @use(i1 %t.1)
%t.2 = icmp ult i32 %X, 124
call void @use(i1 %t.2)
%f.1 = icmp eq i32 %X, 124
call void @use(i1 %f.1)
%f.2 = icmp ugt i32 %X, 123
call void @use(i1 %f.2)
%c.1 = icmp eq i32 %X, 20
call void @use(i1 %c.1)
ret void
}
define void @test1b(i1 %c) {
; CHECK-LABEL: @test1b(
; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]]
; CHECK: T:
; CHECK-NEXT: store i32 17, i32* @G
; CHECK-NEXT: ret void
; CHECK: F:
; CHECK-NEXT: store i32 123, i32* @G
; CHECK-NEXT: ret void
;
br i1 %c, label %T, label %F
T:
store i32 17, i32* @G
ret void
F:
store i32 123, i32* @G
ret void
}
@H = internal global i32 0
define void @test2a() {
; CHECK-LABEL: @test2a(
; CHECK-NEXT: [[X:%.*]] = load i32, i32* @H
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_1:%.*]] = icmp eq i32 [[X]], 20
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: ret void
;
%X = load i32, i32* @H
%t.1 = icmp ne i32 %X, 124
call void @use(i1 %t.1)
%t.2 = icmp ult i32 %X, 124
call void @use(i1 %t.2)
%f.1 = icmp eq i32 %X, 124
call void @use(i1 %f.1)
%f.2 = icmp ugt i32 %X, 123
call void @use(i1 %f.2)
%c.1 = icmp eq i32 %X, 20
call void @use(i1 %c.1)
ret void
}
define void @test2b(i1 %c.1, i1 %c.2) {
; CHECK-LABEL: @test2b(
; CHECK-NEXT: br i1 [[C_1:%.*]], label [[T:%.*]], label [[F:%.*]]
; CHECK: T:
; CHECK-NEXT: br i1 [[C_2:%.*]], label [[T_1:%.*]], label [[F_1:%.*]]
; CHECK: T.1:
; CHECK-NEXT: store i32 17, i32* @H
; CHECK-NEXT: ret void
; CHECK: F.1:
; CHECK-NEXT: store i32 20, i32* @H
; CHECK-NEXT: ret void
; CHECK: F:
; CHECK-NEXT: store i32 123, i32* @H
; CHECK-NEXT: ret void
;
br i1 %c.1, label %T, label %F
T:
br i1 %c.2, label %T.1, label %F.1
T.1:
store i32 17, i32* @H
ret void
F.1:
store i32 20, i32* @H
ret void
F:
store i32 123, i32* @H
ret void
}
@I = internal global i32 0
define void @test3a() {
; CHECK-LABEL: @test3a(
; CHECK-NEXT: [[X:%.*]] = load i32, i32* @I
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_1:%.*]] = icmp eq i32 [[X]], 20
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: ret void
;
%X = load i32, i32* @I
%t.1 = icmp ne i32 %X, 124
call void @use(i1 %t.1)
%t.2 = icmp ult i32 %X, 124
call void @use(i1 %t.2)
%f.1 = icmp eq i32 %X, 124
call void @use(i1 %f.1)
%f.2 = icmp ugt i32 %X, 123
call void @use(i1 %f.2)
%c.1 = icmp eq i32 %X, 20
call void @use(i1 %c.1)
ret void
}
define void @test3b(i1 %c.1, i1 %c.2) {
; CHECK-LABEL: @test3b(
; CHECK-NEXT: br i1 [[C_1:%.*]], label [[T:%.*]], label [[F:%.*]]
; CHECK: T:
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: F:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 17, [[T]] ], [ 123, [[F]] ]
; CHECK-NEXT: store i32 [[P]], i32* @I
; CHECK-NEXT: ret void
;
br i1 %c.1, label %T, label %F
T:
br label %exit
F:
br label %exit
exit:
%p = phi i32 [ 17, %T ], [ 123, %F ]
store i32 %p, i32* @I
ret void
}
; Make sure stored values are correctly updated to overdefined.
@J = internal global i32 0
define void @test4a() {
; CHECK-LABEL: @test4a(
; CHECK-NEXT: [[X:%.*]] = load i32, i32* @J
; CHECK-NEXT: [[C_1:%.*]] = icmp ne i32 [[X]], 124
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: [[C_2:%.*]] = icmp ult i32 [[X]], 124
; CHECK-NEXT: call void @use(i1 [[C_2]])
; CHECK-NEXT: [[C_3:%.*]] = icmp eq i32 [[X]], 124
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: [[C_4:%.*]] = icmp ugt i32 [[X]], 123
; CHECK-NEXT: call void @use(i1 [[C_4]])
; CHECK-NEXT: [[C_5:%.*]] = icmp eq i32 [[X]], 20
; CHECK-NEXT: call void @use(i1 [[C_5]])
; CHECK-NEXT: ret void
;
%X = load i32, i32* @J
%c.1 = icmp ne i32 %X, 124
call void @use(i1 %c.1)
%c.2 = icmp ult i32 %X, 124
call void @use(i1 %c.2)
%c.3 = icmp eq i32 %X, 124
call void @use(i1 %c.3)
%c.4 = icmp ugt i32 %X, 123
call void @use(i1 %c.4)
%c.5 = icmp eq i32 %X, 20
call void @use(i1 %c.5)
ret void
}
define void @test4b(i1 %c.1, i1 %c.2, i32 %x) {
; CHECK-LABEL: @test4b(
; CHECK-NEXT: br i1 [[C_1:%.*]], label [[T:%.*]], label [[F:%.*]]
; CHECK: T:
; CHECK-NEXT: br i1 [[C_2:%.*]], label [[T_1:%.*]], label [[F_1:%.*]]
; CHECK: T.1:
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: F.1:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: F:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 17, [[T_1]] ], [ [[X:%.*]], [[F_1]] ], [ 123, [[F]] ]
; CHECK-NEXT: store i32 [[P]], i32* @J
; CHECK-NEXT: ret void
;
br i1 %c.1, label %T, label %F
T:
br i1 %c.2, label %T.1, label %F.1
T.1:
br label %exit
F.1:
br label %exit
F:
br label %exit
exit:
%p = phi i32 [ 17, %T.1 ], [ %x, %F.1 ], [ 123, %F ]
store i32 %p, i32* @J
ret void
}
; Same as test1, but storing 4 different values.
@K = internal global i32 501
define void @test5a() {
; CHECK-LABEL: @test5a(
; CHECK-NEXT: [[X:%.*]] = load i32, i32* @K
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_1:%.*]] = icmp eq i32 [[X]], 510
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: ret void
;
%X = load i32, i32* @K
%t.1 = icmp ne i32 %X, 499
call void @use(i1 %t.1)
%t.2 = icmp ult i32 %X, 600
call void @use(i1 %t.2)
%f.1 = icmp eq i32 %X, 600
call void @use(i1 %f.1)
%f.2 = icmp ugt i32 %X, 600
call void @use(i1 %f.2)
%c.1 = icmp eq i32 %X, 510
call void @use(i1 %c.1)
ret void
}
define void @test5b(i1 %c.1, i1 %c.2) {
; CHECK-LABEL: @test5b(
; CHECK-NEXT: br i1 [[C_1:%.*]], label [[T_1:%.*]], label [[F_1:%.*]]
; CHECK: T.1:
; CHECK-NEXT: br i1 [[C_2:%.*]], label [[T_2:%.*]], label [[F_2:%.*]]
; CHECK: T.2:
; CHECK-NEXT: store i32 500, i32* @K
; CHECK-NEXT: ret void
; CHECK: F.2:
; CHECK-NEXT: store i32 510, i32* @K
; CHECK-NEXT: ret void
; CHECK: F.1:
; CHECK-NEXT: br i1 [[C_2]], label [[T_3:%.*]], label [[F_3:%.*]]
; CHECK: T.3:
; CHECK-NEXT: store i32 520, i32* @K
; CHECK-NEXT: ret void
; CHECK: F.3:
; CHECK-NEXT: store i32 530, i32* @K
; CHECK-NEXT: ret void
;
br i1 %c.1, label %T.1, label %F.1
T.1:
br i1 %c.2, label %T.2, label %F.2
T.2:
store i32 500, i32* @K
ret void
F.2:
store i32 510, i32* @K
ret void
F.1:
br i1 %c.2, label %T.3, label %F.3
T.3:
store i32 520, i32* @K
ret void
F.3:
store i32 530, i32* @K
ret void
}