@@ -799,6 +799,68 @@ define i32 @test45_commuted3(i32 %x, i32 %y, i32 %z) {
799
799
ret i32 %or1
800
800
}
801
801
802
+ define i32 @test45a (i32 %x , i32 %y , i32 %z ) {
803
+ ; CHECK-LABEL: @test45a(
804
+ ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[Y:%.*]], [[Z:%.*]]
805
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[XOR]], [[X:%.*]]
806
+ ; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[Y]]
807
+ ; CHECK-NEXT: ret i32 [[OR]]
808
+ ;
809
+ %xor = xor i32 %y , %z
810
+ %and = and i32 %x , %xor
811
+ %or = or i32 %and , %y
812
+ ret i32 %or
813
+ }
814
+
815
+ define i32 @test45a_commuted1 (i32 %x , i32 %y , i32 %z ) {
816
+ ; CHECK-LABEL: @test45a_commuted1(
817
+ ; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
818
+ ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[YY]], [[Z:%.*]]
819
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[XOR]], [[X:%.*]]
820
+ ; CHECK-NEXT: [[OR:%.*]] = or i32 [[YY]], [[AND]]
821
+ ; CHECK-NEXT: ret i32 [[OR]]
822
+ ;
823
+ %yy = mul i32 %y , %y ; thwart complexity-based ordering
824
+ %xor = xor i32 %yy , %z
825
+ %and = and i32 %xor , %x
826
+ %or = or i32 %yy , %and
827
+ ret i32 %or
828
+ }
829
+
830
+ define i32 @test45a_commuted2 (i32 %x , i32 %y , i32 %z ) {
831
+ ; CHECK-LABEL: @test45a_commuted2(
832
+ ; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
833
+ ; CHECK-NEXT: [[XX:%.*]] = mul i32 [[X:%.*]], [[X]]
834
+ ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[YY]], [[Z:%.*]]
835
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[XX]], [[XOR]]
836
+ ; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[YY]]
837
+ ; CHECK-NEXT: ret i32 [[OR]]
838
+ ;
839
+ %yy = mul i32 %y , %y ; thwart complexity-based ordering
840
+ %xx = mul i32 %x , %x ; thwart complexity-based ordering
841
+ %xor = xor i32 %yy , %z
842
+ %and = and i32 %xx , %xor
843
+ %or = or i32 %and , %yy
844
+ ret i32 %or
845
+ }
846
+
847
+ define i32 @test45a_commuted3 (i32 %x , i32 %y , i32 %z ) {
848
+ ; CHECK-LABEL: @test45a_commuted3(
849
+ ; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
850
+ ; CHECK-NEXT: [[ZZ:%.*]] = mul i32 [[Z:%.*]], [[Z]]
851
+ ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[ZZ]], [[YY]]
852
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[XOR]], [[X:%.*]]
853
+ ; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[YY]]
854
+ ; CHECK-NEXT: ret i32 [[OR]]
855
+ ;
856
+ %yy = mul i32 %y , %y ; thwart complexity-based ordering
857
+ %zz = mul i32 %z , %z ; thwart complexity-based ordering
858
+ %xor = xor i32 %zz , %yy
859
+ %and = and i32 %xor , %x
860
+ %or = or i32 %and , %yy
861
+ ret i32 %or
862
+ }
863
+
802
864
define i1 @test46 (i8 signext %c ) {
803
865
; CHECK-LABEL: @test46(
804
866
; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[C:%.*]], -33
@@ -1242,13 +1304,13 @@ define i1 @orn_and_cmp_4_logical(i32 %a, i32 %b, i32 %c) {
1242
1304
; The constant vectors are inverses. Make sure we can turn this into a select without crashing trying to truncate the constant to 16xi1.
1243
1305
define <16 x i1 > @test51 (<16 x i1 > %arg , <16 x i1 > %arg1 ) {
1244
1306
; CHECK-LABEL: @test51(
1245
- ; CHECK-NEXT: [[TMP3 :%.*]] = shufflevector <16 x i1> [[ARG:%.*]], <16 x i1> [[ARG1:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 20, i32 5, i32 6, i32 23, i32 24, i32 9, i32 10, i32 27, i32 28, i32 29, i32 30, i32 31>
1246
- ; CHECK-NEXT: ret <16 x i1> [[TMP3 ]]
1307
+ ; CHECK-NEXT: [[RET :%.*]] = shufflevector <16 x i1> [[ARG:%.*]], <16 x i1> [[ARG1:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 20, i32 5, i32 6, i32 23, i32 24, i32 9, i32 10, i32 27, i32 28, i32 29, i32 30, i32 31>
1308
+ ; CHECK-NEXT: ret <16 x i1> [[RET ]]
1247
1309
;
1248
1310
%tmp = and <16 x i1 > %arg , <i1 true , i1 true , i1 true , i1 true , i1 false , i1 true , i1 true , i1 false , i1 false , i1 true , i1 true , i1 false , i1 false , i1 false , i1 false , i1 false >
1249
1311
%tmp2 = and <16 x i1 > %arg1 , <i1 false , i1 false , i1 false , i1 false , i1 true , i1 false , i1 false , i1 true , i1 true , i1 false , i1 false , i1 true , i1 true , i1 true , i1 true , i1 true >
1250
- %tmp3 = or <16 x i1 > %tmp , %tmp2
1251
- ret <16 x i1 > %tmp3
1312
+ %ret = or <16 x i1 > %tmp , %tmp2
1313
+ ret <16 x i1 > %ret
1252
1314
}
1253
1315
1254
1316
; This would infinite loop because it reaches a transform
0 commit comments