@@ -149,6 +149,16 @@ define i1 @test_two_ranges(ptr nocapture readonly %arg1, ptr nocapture readonly
149
149
ret i1 %rval
150
150
}
151
151
152
+ ; Values' ranges overlap each other, so it can not be simplified.
153
+ define i1 @test_two_attribute_ranges (i32 range(i32 5 , 10 ) %arg1 , i32 range(i32 8 , 16 ) %arg2 ) {
154
+ ; CHECK-LABEL: @test_two_attribute_ranges(
155
+ ; CHECK-NEXT: [[RVAL:%.*]] = icmp ult i32 [[ARG1:%.*]], [[ARG2:%.*]]
156
+ ; CHECK-NEXT: ret i1 [[RVAL]]
157
+ ;
158
+ %rval = icmp ult i32 %arg2 , %arg1
159
+ ret i1 %rval
160
+ }
161
+
152
162
; Values' ranges do not overlap each other, so it can simplified to false.
153
163
define i1 @test_two_ranges2 (ptr nocapture readonly %arg1 , ptr nocapture readonly %arg2 ) {
154
164
; CHECK-LABEL: @test_two_ranges2(
@@ -160,6 +170,35 @@ define i1 @test_two_ranges2(ptr nocapture readonly %arg1, ptr nocapture readonly
160
170
ret i1 %rval
161
171
}
162
172
173
+ ; Values' ranges do not overlap each other, so it can simplified to false.
174
+ define i1 @test_two_argument_ranges (i32 range(i32 1 , 6 ) %arg1 , i32 range(i32 8 , 16 ) %arg2 ) {
175
+ ; CHECK-LABEL: @test_two_argument_ranges(
176
+ ; CHECK-NEXT: ret i1 false
177
+ ;
178
+ %rval = icmp ult i32 %arg2 , %arg1
179
+ ret i1 %rval
180
+ }
181
+
182
+ ; Values' ranges do not overlap each other, so it can simplified to false.
183
+ define i1 @test_one_range_and_one_argument_range (ptr nocapture readonly %arg1 , i32 range(i32 8 , 16 ) %arg2 ) {
184
+ ; CHECK-LABEL: @test_one_range_and_one_argument_range(
185
+ ; CHECK-NEXT: ret i1 false
186
+ ;
187
+ %val1 = load i32 , ptr %arg1 , !range !0
188
+ %rval = icmp ult i32 %arg2 , %val1
189
+ ret i1 %rval
190
+ }
191
+
192
+ ; Values' ranges do not overlap each other, so it can simplified to false.
193
+ define i1 @test_one_argument_range_and_one_range (i32 range(i32 1 , 6 ) %arg1 , ptr nocapture readonly %arg2 ) {
194
+ ; CHECK-LABEL: @test_one_argument_range_and_one_range(
195
+ ; CHECK-NEXT: ret i1 false
196
+ ;
197
+ %val1 = load i32 , ptr %arg2 , !range !6
198
+ %rval = icmp ult i32 %val1 , %arg1
199
+ ret i1 %rval
200
+ }
201
+
163
202
; Values' ranges do not overlap each other, so it can simplified to true.
164
203
define i1 @test_two_ranges3 (ptr nocapture readonly %arg1 , ptr nocapture readonly %arg2 ) {
165
204
; CHECK-LABEL: @test_two_ranges3(
@@ -186,8 +225,8 @@ define <2 x i1> @test_two_ranges_vec(ptr nocapture readonly %arg1, ptr nocapture
186
225
}
187
226
188
227
; Values' ranges do not overlap each other, so it can simplified to false.
189
- define <2 x i1 > @test_two_ranges_vec_true (ptr nocapture readonly %arg1 , ptr nocapture readonly %arg2 ) {
190
- ; CHECK-LABEL: @test_two_ranges_vec_true (
228
+ define <2 x i1 > @test_two_ranges_vec_false (ptr nocapture readonly %arg1 , ptr nocapture readonly %arg2 ) {
229
+ ; CHECK-LABEL: @test_two_ranges_vec_false (
191
230
; CHECK-NEXT: ret <2 x i1> zeroinitializer
192
231
;
193
232
%val1 = load <2 x i32 >, ptr %arg1 , !range !0
@@ -196,9 +235,9 @@ define <2 x i1> @test_two_ranges_vec_true(ptr nocapture readonly %arg1, ptr noca
196
235
ret <2 x i1 > %rval
197
236
}
198
237
199
- ; Values' ranges do not overlap each other, so it can simplified to false .
200
- define <2 x i1 > @test_two_ranges_vec_false (ptr nocapture readonly %arg1 , ptr nocapture readonly %arg2 ) {
201
- ; CHECK-LABEL: @test_two_ranges_vec_false (
238
+ ; Values' ranges do not overlap each other, so it can simplified to true .
239
+ define <2 x i1 > @test_two_ranges_vec_true (ptr nocapture readonly %arg1 , ptr nocapture readonly %arg2 ) {
240
+ ; CHECK-LABEL: @test_two_ranges_vec_true (
202
241
; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
203
242
;
204
243
%val1 = load <2 x i32 >, ptr %arg1 , !range !0
@@ -207,6 +246,101 @@ define <2 x i1> @test_two_ranges_vec_false(ptr nocapture readonly %arg1, ptr noc
207
246
ret <2 x i1 > %rval
208
247
}
209
248
249
+ ; Values' ranges overlap each other, so it can not be simplified.
250
+ define <2 x i1 > @test_two_argument_ranges_vec (<2 x i32 > range(i32 5 , 10 ) %arg1 , <2 x i32 > range(i32 8 , 16 ) %arg2 ) {
251
+ ; CHECK-LABEL: @test_two_argument_ranges_vec(
252
+ ; CHECK-NEXT: [[RVAL:%.*]] = icmp ult <2 x i32> [[VAL2:%.*]], [[VAL1:%.*]]
253
+ ; CHECK-NEXT: ret <2 x i1> [[RVAL]]
254
+ ;
255
+ %rval = icmp ult <2 x i32 > %arg2 , %arg1
256
+ ret <2 x i1 > %rval
257
+ }
258
+
259
+ ; Values' ranges do not overlap each other, so it can simplified to false.
260
+ define <2 x i1 > @test_two_argument_ranges_vec_false (<2 x i32 > range(i32 1 , 6 ) %arg1 , <2 x i32 > range(i32 8 , 16 ) %arg2 ) {
261
+ ; CHECK-LABEL: @test_two_argument_ranges_vec_false(
262
+ ; CHECK-NEXT: ret <2 x i1> zeroinitializer
263
+ ;
264
+ %rval = icmp ult <2 x i32 > %arg2 , %arg1
265
+ ret <2 x i1 > %rval
266
+ }
267
+
268
+ ; Values' ranges do not overlap each other, so it can simplified to true.
269
+ define <2 x i1 > @test_two_argument_ranges_vec_true (<2 x i32 > range(i32 1 , 6 ) %arg1 , <2 x i32 > range(i32 8 , 16 ) %arg2 ) {
270
+ ; CHECK-LABEL: @test_two_argument_ranges_vec_true(
271
+ ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
272
+ ;
273
+ %rval = icmp ugt <2 x i32 > %arg2 , %arg1
274
+ ret <2 x i1 > %rval
275
+ }
276
+
277
+ declare i32 @create_range1 ()
278
+ declare range(i32 8 , 16 ) i32 @create_range2 ()
279
+ declare range(i32 1 , 6 ) i32 @create_range3 ()
280
+
281
+ ; Values' ranges overlap each other, so it can not be simplified.
282
+ define i1 @test_two_return_attribute_ranges_not_simplified () {
283
+ ; CHECK-LABEL: @test_two_return_attribute_ranges_not_simplified(
284
+ ; CHECK-NEXT: [[ARG2:%.*]] = call range(i32 5, 10) i32 @create_range1()
285
+ ; CHECK-NEXT: [[ARG1:%.*]] = call i32 @create_range2()
286
+ ; CHECK-NEXT: [[RVAL:%.*]] = icmp ult i32 [[ARG1]], [[ARG2]]
287
+ ; CHECK-NEXT: ret i1 [[RVAL]]
288
+ ;
289
+ %val1 = call range(i32 5 , 10 ) i32 @create_range1 ()
290
+ %val2 = call i32 @create_range2 ()
291
+ %rval = icmp ult i32 %val2 , %val1
292
+ ret i1 %rval
293
+ }
294
+
295
+ ; Values' ranges do not overlap each other, so it can simplified to false.
296
+ define i1 @test_two_return_attribute_ranges_one_in_call () {
297
+ ; CHECK-LABEL: @test_two_return_attribute_ranges_one_in_call(
298
+ ; CHECK-NEXT: [[VAL1:%.*]] = call range(i32 1, 6) i32 @create_range1()
299
+ ; CHECK-NEXT: [[ARG1:%.*]] = call i32 @create_range2()
300
+ ; CHECK-NEXT: ret i1 false
301
+ ;
302
+ %val1 = call range(i32 1 , 6 ) i32 @create_range1 ()
303
+ %val2 = call i32 @create_range2 ()
304
+ %rval = icmp ult i32 %val2 , %val1
305
+ ret i1 %rval
306
+ }
307
+
308
+ ; Values' ranges do not overlap each other, so it can simplified to false.
309
+ define i1 @test_two_return_attribute_ranges () {
310
+ ; CHECK-LABEL: @test_two_return_attribute_ranges(
311
+ ; CHECK-NEXT: [[VAL1:%.*]] = call i32 @create_range3()
312
+ ; CHECK-NEXT: [[ARG1:%.*]] = call i32 @create_range2()
313
+ ; CHECK-NEXT: ret i1 false
314
+ ;
315
+ %val1 = call i32 @create_range3 ()
316
+ %val2 = call i32 @create_range2 ()
317
+ %rval = icmp ult i32 %val2 , %val1
318
+ ret i1 %rval
319
+ }
320
+
321
+ ; Values' ranges do not overlap each other, so it can simplified to false.
322
+ define i1 @test_one_return_argument_and_one_argument_range (i32 range(i32 8 , 16 ) %arg1 ) {
323
+ ; CHECK-LABEL: @test_one_return_argument_and_one_argument_range(
324
+ ; CHECK-NEXT: [[VAL1:%.*]] = call i32 @create_range3()
325
+ ; CHECK-NEXT: ret i1 false
326
+ ;
327
+ %val1 = call i32 @create_range3 ()
328
+ %rval = icmp ult i32 %arg1 , %val1
329
+ ret i1 %rval
330
+ }
331
+
332
+ ; Values' ranges do not overlap each other, so it can simplified to false.
333
+ define i1 @test_one_range_and_one_return_argument (ptr nocapture readonly %arg1 ) {
334
+ ; CHECK-LABEL: @test_one_range_and_one_return_argument(
335
+ ; CHECK-NEXT: [[VAL1:%.*]] = call i32 @create_range3()
336
+ ; CHECK-NEXT: ret i1 false
337
+ ;
338
+ %val1 = call i32 @create_range3 ()
339
+ %val2 = load i32 , ptr %arg1 , !range !6
340
+ %rval = icmp ult i32 %val2 , %val1
341
+ ret i1 %rval
342
+ }
343
+
210
344
define i1 @ugt_zext (i1 %b , i8 %x ) {
211
345
; CHECK-LABEL: @ugt_zext(
212
346
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], 0
0 commit comments