@@ -487,8 +487,8 @@ define i12 @trunc_sandwich_use1(i32 %x) {
487
487
; CHECK-LABEL: @trunc_sandwich_use1(
488
488
; CHECK-NEXT: [[SH:%.*]] = lshr i32 [[X:%.*]], 28
489
489
; CHECK-NEXT: call void @use(i32 [[SH]])
490
- ; CHECK-NEXT: [[TR :%.*]] = trunc i32 [[SH]] to i12
491
- ; CHECK-NEXT: [[R:%.*]] = lshr i12 [[TR]], 2
490
+ ; CHECK-NEXT: [[SUM_SHIFT :%.*]] = lshr i32 [[X]], 30
491
+ ; CHECK-NEXT: [[R:%.*]] = trunc i32 [[SUM_SHIFT]] to i12
492
492
; CHECK-NEXT: ret i12 [[R]]
493
493
;
494
494
%sh = lshr i32 %x , 28
@@ -502,8 +502,8 @@ define <3 x i9> @trunc_sandwich_splat_vec_use1(<3 x i14> %x) {
502
502
; CHECK-LABEL: @trunc_sandwich_splat_vec_use1(
503
503
; CHECK-NEXT: [[SH:%.*]] = lshr <3 x i14> [[X:%.*]], <i14 6, i14 6, i14 6>
504
504
; CHECK-NEXT: call void @usevec(<3 x i14> [[SH]])
505
- ; CHECK-NEXT: [[TR :%.*]] = trunc <3 x i14> [[SH]] to <3 x i9 >
506
- ; CHECK-NEXT: [[R:%.*]] = lshr <3 x i9 > [[TR]], <i9 5, i9 5, i9 5 >
505
+ ; CHECK-NEXT: [[SUM_SHIFT :%.*]] = lshr <3 x i14> [[X]], <i14 11, i14 11, i14 11 >
506
+ ; CHECK-NEXT: [[R:%.*]] = trunc <3 x i14 > [[SUM_SHIFT]] to <3 x i9>
507
507
; CHECK-NEXT: ret <3 x i9> [[R]]
508
508
;
509
509
%sh = lshr <3 x i14 > %x , <i14 6 , i14 6 , i14 6 >
@@ -517,8 +517,8 @@ define i12 @trunc_sandwich_min_shift1_use1(i32 %x) {
517
517
; CHECK-LABEL: @trunc_sandwich_min_shift1_use1(
518
518
; CHECK-NEXT: [[SH:%.*]] = lshr i32 [[X:%.*]], 20
519
519
; CHECK-NEXT: call void @use(i32 [[SH]])
520
- ; CHECK-NEXT: [[TR :%.*]] = trunc i32 [[SH]] to i12
521
- ; CHECK-NEXT: [[R:%.*]] = lshr i12 [[TR]], 1
520
+ ; CHECK-NEXT: [[SUM_SHIFT :%.*]] = lshr i32 [[X]], 21
521
+ ; CHECK-NEXT: [[R:%.*]] = trunc i32 [[SUM_SHIFT]] to i12
522
522
; CHECK-NEXT: ret i12 [[R]]
523
523
;
524
524
%sh = lshr i32 %x , 20
@@ -528,6 +528,8 @@ define i12 @trunc_sandwich_min_shift1_use1(i32 %x) {
528
528
ret i12 %r
529
529
}
530
530
531
+ ; negative test - trunc is bigger than first shift
532
+
531
533
define i12 @trunc_sandwich_small_shift1_use1 (i32 %x ) {
532
534
; CHECK-LABEL: @trunc_sandwich_small_shift1_use1(
533
535
; CHECK-NEXT: [[SH:%.*]] = lshr i32 [[X:%.*]], 19
@@ -547,8 +549,8 @@ define i12 @trunc_sandwich_max_sum_shift_use1(i32 %x) {
547
549
; CHECK-LABEL: @trunc_sandwich_max_sum_shift_use1(
548
550
; CHECK-NEXT: [[SH:%.*]] = lshr i32 [[X:%.*]], 20
549
551
; CHECK-NEXT: call void @use(i32 [[SH]])
550
- ; CHECK-NEXT: [[TR :%.*]] = trunc i32 [[SH]] to i12
551
- ; CHECK-NEXT: [[R:%.*]] = lshr i12 [[TR]], 11
552
+ ; CHECK-NEXT: [[SUM_SHIFT :%.*]] = lshr i32 [[X]], 31
553
+ ; CHECK-NEXT: [[R:%.*]] = trunc i32 [[SUM_SHIFT]] to i12
552
554
; CHECK-NEXT: ret i12 [[R]]
553
555
;
554
556
%sh = lshr i32 %x , 20
@@ -562,8 +564,8 @@ define i12 @trunc_sandwich_max_sum_shift2_use1(i32 %x) {
562
564
; CHECK-LABEL: @trunc_sandwich_max_sum_shift2_use1(
563
565
; CHECK-NEXT: [[SH:%.*]] = lshr i32 [[X:%.*]], 30
564
566
; CHECK-NEXT: call void @use(i32 [[SH]])
565
- ; CHECK-NEXT: [[TR :%.*]] = trunc i32 [[SH]] to i12
566
- ; CHECK-NEXT: [[R:%.*]] = lshr i12 [[TR]], 1
567
+ ; CHECK-NEXT: [[SUM_SHIFT :%.*]] = lshr i32 [[X]], 31
568
+ ; CHECK-NEXT: [[R:%.*]] = trunc i32 [[SUM_SHIFT]] to i12
567
569
; CHECK-NEXT: ret i12 [[R]]
568
570
;
569
571
%sh = lshr i32 %x , 30
@@ -573,6 +575,8 @@ define i12 @trunc_sandwich_max_sum_shift2_use1(i32 %x) {
573
575
ret i12 %r
574
576
}
575
577
578
+ ; negative test - but overshift is simplified to zero by another fold
579
+
576
580
define i12 @trunc_sandwich_big_sum_shift1_use1 (i32 %x ) {
577
581
; CHECK-LABEL: @trunc_sandwich_big_sum_shift1_use1(
578
582
; CHECK-NEXT: [[SH:%.*]] = lshr i32 [[X:%.*]], 21
@@ -586,6 +590,8 @@ define i12 @trunc_sandwich_big_sum_shift1_use1(i32 %x) {
586
590
ret i12 %r
587
591
}
588
592
593
+ ; negative test - but overshift is simplified to zero by another fold
594
+
589
595
define i12 @trunc_sandwich_big_sum_shift2_use1 (i32 %x ) {
590
596
; CHECK-LABEL: @trunc_sandwich_big_sum_shift2_use1(
591
597
; CHECK-NEXT: [[SH:%.*]] = lshr i32 [[X:%.*]], 31
0 commit comments