@@ -279,11 +279,11 @@ for.end: ; preds = %for.body, %entry
279
279
define void @rhs_narrow_range (i16 %n.raw ) {
280
280
; CHECK-LABEL: 'rhs_narrow_range'
281
281
; CHECK-NEXT: Determining loop execution counts for: @rhs_narrow_range
282
- ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
283
- ; CHECK-NEXT: Loop %for.body: Unpredictable max backedge-taken count.
282
+ ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 umax (2 * (zext i7 (trunc i16 (%n.raw /u 2) to i7) to i16))<nuw><nsw>))<nsw>
283
+ ; CHECK-NEXT: Loop %for.body: max backedge-taken count is 253
284
284
; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (1 umax (2 * (zext i7 (trunc i16 (%n.raw /u 2) to i7) to i16))<nuw><nsw>))<nsw>
285
285
; CHECK-NEXT: Predicates:
286
- ; CHECK-NEXT : {1,+,1}< %for.body> Added Flags: <nusw>
286
+ ; CHECK: Loop %for.body: Trip multiple is 1
287
287
;
288
288
entry:
289
289
%n = and i16 %n.raw , 254
@@ -301,6 +301,150 @@ for.end: ; preds = %for.body, %entry
301
301
ret void
302
302
}
303
303
304
+ define void @ugt_constant_rhs (i16 %n.raw , i8 %start ) mustprogress {
305
+ ;
306
+ ; CHECK-LABEL: 'ugt_constant_rhs'
307
+ ; CHECK-NEXT: Determining loop execution counts for: @ugt_constant_rhs
308
+ ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
309
+ ; CHECK-NEXT: Loop %for.body: Unpredictable max backedge-taken count.
310
+ ; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count.
311
+ ;
312
+ entry:
313
+ br label %for.body
314
+
315
+ for.body: ; preds = %entry, %for.body
316
+ %iv = phi i8 [ %iv.next , %for.body ], [ %start , %entry ]
317
+ %iv.next = add i8 %iv , 1
318
+ %zext = zext i8 %iv.next to i16
319
+ %cmp = icmp ugt i16 %zext , 254
320
+ br i1 %cmp , label %for.body , label %for.end
321
+
322
+ for.end: ; preds = %for.body, %entry
323
+ ret void
324
+ }
325
+
326
+ define void @ult_constant_rhs (i16 %n.raw , i8 %start ) {
327
+ ;
328
+ ; CHECK-LABEL: 'ult_constant_rhs'
329
+ ; CHECK-NEXT: Determining loop execution counts for: @ult_constant_rhs
330
+ ; CHECK-NEXT: Loop %for.body: backedge-taken count is (255 + (-1 * (zext i8 (1 + %start) to i16))<nsw>)<nsw>
331
+ ; CHECK-NEXT: Loop %for.body: max backedge-taken count is 255
332
+ ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (255 + (-1 * (zext i8 (1 + %start) to i16))<nsw>)<nsw>
333
+ ; CHECK-NEXT: Predicates:
334
+ ; CHECK: Loop %for.body: Trip multiple is 1
335
+ ;
336
+ entry:
337
+ br label %for.body
338
+
339
+ for.body: ; preds = %entry, %for.body
340
+ %iv = phi i8 [ %iv.next , %for.body ], [ %start , %entry ]
341
+ %iv.next = add i8 %iv , 1
342
+ %zext = zext i8 %iv.next to i16
343
+ %cmp = icmp ult i16 %zext , 255
344
+ br i1 %cmp , label %for.body , label %for.end
345
+
346
+ for.end: ; preds = %for.body, %entry
347
+ ret void
348
+ }
349
+
350
+ define void @ult_constant_rhs_stride2 (i16 %n.raw , i8 %start ) {
351
+ ;
352
+ ; CHECK-LABEL: 'ult_constant_rhs_stride2'
353
+ ; CHECK-NEXT: Determining loop execution counts for: @ult_constant_rhs_stride2
354
+ ; CHECK-NEXT: Loop %for.body: backedge-taken count is ((1 + (-1 * (zext i8 (2 + %start) to i16))<nsw> + (254 umax (zext i8 (2 + %start) to i16))) /u 2)
355
+ ; CHECK-NEXT: Loop %for.body: max backedge-taken count is 127
356
+ ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((1 + (-1 * (zext i8 (2 + %start) to i16))<nsw> + (254 umax (zext i8 (2 + %start) to i16))) /u 2)
357
+ ; CHECK-NEXT: Predicates:
358
+ ; CHECK: Loop %for.body: Trip multiple is 1
359
+ ;
360
+ entry:
361
+ br label %for.body
362
+
363
+ for.body: ; preds = %entry, %for.body
364
+ %iv = phi i8 [ %iv.next , %for.body ], [ %start , %entry ]
365
+ %iv.next = add i8 %iv , 2
366
+ %zext = zext i8 %iv.next to i16
367
+ %cmp = icmp ult i16 %zext , 254
368
+ br i1 %cmp , label %for.body , label %for.end
369
+
370
+ for.end: ; preds = %for.body, %entry
371
+ ret void
372
+ }
373
+
374
+ define void @ult_constant_rhs_stride2_neg (i16 %n.raw , i8 %start ) {
375
+ ;
376
+ ; CHECK-LABEL: 'ult_constant_rhs_stride2_neg'
377
+ ; CHECK-NEXT: Determining loop execution counts for: @ult_constant_rhs_stride2_neg
378
+ ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
379
+ ; CHECK-NEXT: Loop %for.body: Unpredictable max backedge-taken count.
380
+ ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((256 + (-1 * (zext i8 (2 + %start) to i16))<nsw>)<nsw> /u 2)
381
+ ; CHECK-NEXT: Predicates:
382
+ ; CHECK-NEXT: {(2 + %start),+,2}<%for.body> Added Flags: <nusw>
383
+ ;
384
+ entry:
385
+ br label %for.body
386
+
387
+ for.body: ; preds = %entry, %for.body
388
+ %iv = phi i8 [ %iv.next , %for.body ], [ %start , %entry ]
389
+ %iv.next = add i8 %iv , 2
390
+ %zext = zext i8 %iv.next to i16
391
+ %cmp = icmp ult i16 %zext , 255
392
+ br i1 %cmp , label %for.body , label %for.end
393
+
394
+ for.end: ; preds = %for.body, %entry
395
+ ret void
396
+ }
397
+
398
+
399
+ define void @ult_restricted_rhs (i16 %n.raw ) {
400
+ ; CHECK-LABEL: 'ult_restricted_rhs'
401
+ ; CHECK-NEXT: Determining loop execution counts for: @ult_restricted_rhs
402
+ ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 umax (zext i8 (trunc i16 %n.raw to i8) to i16)))<nsw>
403
+ ; CHECK-NEXT: Loop %for.body: max backedge-taken count is 254
404
+ ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (1 umax (zext i8 (trunc i16 %n.raw to i8) to i16)))<nsw>
405
+ ; CHECK-NEXT: Predicates:
406
+ ; CHECK: Loop %for.body: Trip multiple is 1
407
+ ;
408
+ entry:
409
+ %n = and i16 %n.raw , 255
410
+ br label %for.body
411
+
412
+ for.body: ; preds = %entry, %for.body
413
+ %iv = phi i8 [ %iv.next , %for.body ], [ 0 , %entry ]
414
+ %iv.next = add i8 %iv , 1
415
+ %zext = zext i8 %iv.next to i16
416
+ %cmp = icmp ult i16 %zext , %n
417
+ br i1 %cmp , label %for.body , label %for.end
418
+
419
+ for.end: ; preds = %for.body, %entry
420
+ ret void
421
+ }
422
+
423
+ define void @ult_guarded_rhs (i16 %n ) {;
424
+ ; CHECK-LABEL: 'ult_guarded_rhs'
425
+ ; CHECK-NEXT: Determining loop execution counts for: @ult_guarded_rhs
426
+ ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 umax %n))
427
+ ; CHECK-NEXT: Loop %for.body: max backedge-taken count is -2
428
+ ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (1 umax %n))
429
+ ; CHECK-NEXT: Predicates:
430
+ ; CHECK: Loop %for.body: Trip multiple is 1
431
+ ;
432
+ entry:
433
+ %in_range = icmp ult i16 %n , 256
434
+ br i1 %in_range , label %for.body , label %for.end
435
+
436
+ for.body: ; preds = %entry, %for.body
437
+ %iv = phi i8 [ %iv.next , %for.body ], [ 0 , %entry ]
438
+ %iv.next = add i8 %iv , 1
439
+ %zext = zext i8 %iv.next to i16
440
+ %cmp = icmp ult i16 %zext , %n
441
+ br i1 %cmp , label %for.body , label %for.end
442
+
443
+ for.end: ; preds = %for.body, %entry
444
+ ret void
445
+ }
446
+
447
+
304
448
305
449
declare void @llvm.assume (i1 )
306
450
0 commit comments