Skip to content

Commit 865b73a

Browse files
committed
[InstCombine] Add multi-use tests for shift-of-shift transform (NFC)
Also drop irrelevant function attributes from tests.
1 parent 090c92e commit 865b73a

File tree

1 file changed

+45
-19
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+45
-19
lines changed

llvm/test/Transforms/InstCombine/shift.ll

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ define i32 @test26(i32 %A) {
366366
ret i32 %D
367367
}
368368

369-
define i1 @test27(i32 %x) nounwind {
369+
define i1 @test27(i32 %x) {
370370
; CHECK-LABEL: @test27(
371371
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 8
372372
; CHECK-NEXT: [[Z:%.*]] = icmp ne i32 [[TMP1]], 0
@@ -605,7 +605,7 @@ define <2 x i32> @shl_nuw_nsw_splat_vec(<2 x i8> %x) {
605605
ret <2 x i32> %t3
606606
}
607607

608-
define i32 @test38(i32 %x) nounwind readnone {
608+
define i32 @test38(i32 %x) {
609609
; CHECK-LABEL: @test38(
610610
; CHECK-NEXT: [[REM1:%.*]] = and i32 [[X:%.*]], 31
611611
; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 1, [[REM1]]
@@ -616,7 +616,7 @@ define i32 @test38(i32 %x) nounwind readnone {
616616
ret i32 %shl
617617
}
618618

619-
define <2 x i32> @test38_uniform(<2 x i32> %x) nounwind readnone {
619+
define <2 x i32> @test38_uniform(<2 x i32> %x) {
620620
; CHECK-LABEL: @test38_uniform(
621621
; CHECK-NEXT: [[REM1:%.*]] = and <2 x i32> [[X:%.*]], <i32 31, i32 31>
622622
; CHECK-NEXT: [[SHL:%.*]] = shl nuw <2 x i32> <i32 1, i32 1>, [[REM1]]
@@ -627,7 +627,7 @@ define <2 x i32> @test38_uniform(<2 x i32> %x) nounwind readnone {
627627
ret <2 x i32> %shl
628628
}
629629

630-
define <3 x i32> @test38_nonuniform(<3 x i32> %x) nounwind readnone {
630+
define <3 x i32> @test38_nonuniform(<3 x i32> %x) {
631631
; CHECK-LABEL: @test38_nonuniform(
632632
; CHECK-NEXT: [[REM1:%.*]] = and <3 x i32> [[X:%.*]], <i32 31, i32 15, i32 0>
633633
; CHECK-NEXT: [[SHL:%.*]] = shl nuw <3 x i32> <i32 1, i32 1, i32 1>, [[REM1]]
@@ -638,7 +638,7 @@ define <3 x i32> @test38_nonuniform(<3 x i32> %x) nounwind readnone {
638638
ret <3 x i32> %shl
639639
}
640640

641-
define <2 x i32> @test38_poison(<2 x i32> %x) nounwind readnone {
641+
define <2 x i32> @test38_poison(<2 x i32> %x) {
642642
; CHECK-LABEL: @test38_poison(
643643
; CHECK-NEXT: ret <2 x i32> poison
644644
;
@@ -658,8 +658,8 @@ define i8 @test39(i32 %a0) {
658658
; CHECK-NEXT: [[I51:%.*]] = xor i8 [[I50]], [[I5]]
659659
; CHECK-NEXT: [[TMP0:%.*]] = lshr exact i8 [[I5]], 3
660660
; CHECK-NEXT: [[I54:%.*]] = and i8 [[TMP0]], 16
661-
; CHECK-NEXT: [[I551:%.*]] = or disjoint i8 [[I54]], [[I51]]
662-
; CHECK-NEXT: ret i8 [[I551]]
661+
; CHECK-NEXT: [[I55:%.*]] = or disjoint i8 [[I54]], [[I51]]
662+
; CHECK-NEXT: ret i8 [[I55]]
663663
;
664664
entry:
665665
%i4 = trunc i32 %a0 to i8
@@ -675,7 +675,7 @@ entry:
675675
ret i8 %i55
676676
}
677677

678-
define i32 @test42(i32 %a, i32 %b) nounwind {
678+
define i32 @test42(i32 %a, i32 %b) {
679679
; CHECK-LABEL: @test42(
680680
; CHECK-NEXT: [[DIV:%.*]] = lshr exact i32 4096, [[B:%.*]]
681681
; CHECK-NEXT: [[DIV2:%.*]] = udiv i32 [[A:%.*]], [[DIV]]
@@ -697,7 +697,7 @@ define <2 x i32> @test42vec(<2 x i32> %a, <2 x i32> %b) {
697697
ret <2 x i32> %div2
698698
}
699699

700-
define i32 @test43(i32 %a, i32 %b) nounwind {
700+
define i32 @test43(i32 %a, i32 %b) {
701701
; CHECK-LABEL: @test43(
702702
; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[B:%.*]], 12
703703
; CHECK-NEXT: [[DIV21:%.*]] = lshr i32 [[A:%.*]], [[TMP1]]
@@ -708,7 +708,7 @@ define i32 @test43(i32 %a, i32 %b) nounwind {
708708
ret i32 %div2
709709
}
710710

711-
define i32 @test44(i32 %a) nounwind {
711+
define i32 @test44(i32 %a) {
712712
; CHECK-LABEL: @test44(
713713
; CHECK-NEXT: [[Y:%.*]] = shl i32 [[A:%.*]], 5
714714
; CHECK-NEXT: ret i32 [[Y]]
@@ -718,7 +718,20 @@ define i32 @test44(i32 %a) nounwind {
718718
ret i32 %z
719719
}
720720

721-
define i32 @test45(i32 %a) nounwind {
721+
define i32 @test44_multiuse(i32 %a) {
722+
; CHECK-LABEL: @test44_multiuse(
723+
; CHECK-NEXT: [[Y:%.*]] = shl nuw i32 [[A:%.*]], 1
724+
; CHECK-NEXT: call void @use_i32(i32 [[Y]])
725+
; CHECK-NEXT: [[Z:%.*]] = shl i32 [[A]], 5
726+
; CHECK-NEXT: ret i32 [[Z]]
727+
;
728+
%y = shl nuw i32 %a, 1
729+
call void @use_i32(i32 %y)
730+
%z = shl i32 %y, 4
731+
ret i32 %z
732+
}
733+
734+
define i32 @test45(i32 %a) {
722735
; CHECK-LABEL: @test45(
723736
; CHECK-NEXT: [[Y:%.*]] = lshr i32 [[A:%.*]], 5
724737
; CHECK-NEXT: ret i32 [[Y]]
@@ -728,6 +741,19 @@ define i32 @test45(i32 %a) nounwind {
728741
ret i32 %z
729742
}
730743

744+
define i32 @test45_multiuse(i32 %a) {
745+
; CHECK-LABEL: @test45_multiuse(
746+
; CHECK-NEXT: [[Y:%.*]] = lshr exact i32 [[A:%.*]], 1
747+
; CHECK-NEXT: call void @use_i32(i32 [[Y]])
748+
; CHECK-NEXT: [[Z:%.*]] = lshr i32 [[A]], 5
749+
; CHECK-NEXT: ret i32 [[Z]]
750+
;
751+
%y = lshr exact i32 %a, 1
752+
call void @use_i32(i32 %y)
753+
%z = lshr i32 %y, 4
754+
ret i32 %z
755+
}
756+
731757
; (X >>?exact C1) << C2 --> X >>?exact (C1-C2)
732758

733759
define i32 @test46(i32 %a) {
@@ -1751,14 +1777,14 @@ define void @ashr_out_of_range_1(ptr %A) {
17511777
; CHECK-NEXT: [[L:%.*]] = load i177, ptr [[A:%.*]], align 4
17521778
; CHECK-NEXT: [[L_FROZEN:%.*]] = freeze i177 [[L]]
17531779
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i177 [[L_FROZEN]], -1
1754-
; CHECK-NEXT: [[TMP6:%.*]] = trunc i177 [[L_FROZEN]] to i64
1755-
; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i64 0, i64 [[TMP6]]
1756-
; CHECK-NEXT: [[TMP3:%.*]] = getelementptr i177, ptr [[A]], i64 [[TMP2]]
1757-
; CHECK-NEXT: [[G11:%.*]] = getelementptr i8, ptr [[TMP3]], i64 -24
1758-
; CHECK-NEXT: [[TMP4:%.*]] = sext i1 [[TMP1]] to i64
1759-
; CHECK-NEXT: [[G62:%.*]] = getelementptr i177, ptr [[G11]], i64 [[TMP4]]
1760-
; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i177 [[L_FROZEN]], -1
1761-
; CHECK-NEXT: [[B28:%.*]] = select i1 [[TMP5]], i177 0, i177 [[L_FROZEN]]
1780+
; CHECK-NEXT: [[TMP2:%.*]] = trunc i177 [[L_FROZEN]] to i64
1781+
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i64 0, i64 [[TMP2]]
1782+
; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i177, ptr [[A]], i64 [[TMP3]]
1783+
; CHECK-NEXT: [[G11:%.*]] = getelementptr i8, ptr [[TMP4]], i64 -24
1784+
; CHECK-NEXT: [[TMP5:%.*]] = sext i1 [[TMP1]] to i64
1785+
; CHECK-NEXT: [[G62:%.*]] = getelementptr i177, ptr [[G11]], i64 [[TMP5]]
1786+
; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i177 [[L_FROZEN]], -1
1787+
; CHECK-NEXT: [[B28:%.*]] = select i1 [[TMP6]], i177 0, i177 [[L_FROZEN]]
17621788
; CHECK-NEXT: store i177 [[B28]], ptr [[G62]], align 4
17631789
; CHECK-NEXT: ret void
17641790
;

0 commit comments

Comments
 (0)