@@ -1281,10 +1281,10 @@ define <16 x i1> @test51(<16 x i1> %arg, <16 x i1> %arg1) {
1281
1281
; 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>
1282
1282
; CHECK-NEXT: ret <16 x i1> [[TMP3]]
1283
1283
;
1284
- %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 >
1285
- %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 >
1286
- %tmp3 = or <16 x i1 > %tmp , %tmp2
1287
- ret <16 x i1 > %tmp3
1284
+ %out = 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 >
1285
+ %out2 = 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 >
1286
+ %out3 = or <16 x i1 > %out , %out2
1287
+ ret <16 x i1 > %out3
1288
1288
}
1289
1289
1290
1290
; This would infinite loop because it reaches a transform
@@ -2035,3 +2035,82 @@ define i32 @or_xor_and_commuted3(i32 %x, i32 %y, i32 %z) {
2035
2035
%or1 = or i32 %xor , %yy
2036
2036
ret i32 %or1
2037
2037
}
2038
+
2039
+ define i32 @or_combine_mul_and1 (i32 %in ) {
2040
+ ; CHECK-LABEL: @or_combine_mul_and1(
2041
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 6
2042
+ ; CHECK-NEXT: [[OUT:%.*]] = mul nuw nsw i32 [[TMP1]], 72
2043
+ ; CHECK-NEXT: ret i32 [[OUT]]
2044
+ ;
2045
+ %bitop0 = and i32 %in , 2
2046
+ %out0 = mul i32 %bitop0 , 72
2047
+ %bitop1 = and i32 %in , 4
2048
+ %out1 = mul i32 %bitop1 , 72
2049
+ %out = or disjoint i32 %out0 , %out1
2050
+ ret i32 %out
2051
+ }
2052
+
2053
+ define i32 @or_combine_mul_and2 (i32 %in ) {
2054
+ ; CHECK-LABEL: @or_combine_mul_and2(
2055
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 10
2056
+ ; CHECK-NEXT: [[OUT:%.*]] = mul nuw nsw i32 [[TMP1]], 72
2057
+ ; CHECK-NEXT: ret i32 [[OUT]]
2058
+ ;
2059
+ %bitop0 = and i32 %in , 2
2060
+ %out0 = mul i32 %bitop0 , 72
2061
+ %bitop1 = and i32 %in , 8
2062
+ %out1 = mul i32 %bitop1 , 72
2063
+ %out = or disjoint i32 %out0 , %out1
2064
+ ret i32 %out
2065
+ }
2066
+
2067
+ define i32 @or_combine_mul_and_diff_factor (i32 %in ) {
2068
+ ; CHECK-LABEL: @or_combine_mul_and_diff_factor(
2069
+ ; CHECK-NEXT: [[BITOP0:%.*]] = and i32 [[IN:%.*]], 2
2070
+ ; CHECK-NEXT: [[TMP0:%.*]] = mul nuw nsw i32 [[BITOP0]], 36
2071
+ ; CHECK-NEXT: [[BITOP1:%.*]] = and i32 [[IN]], 4
2072
+ ; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i32 [[BITOP1]], 72
2073
+ ; CHECK-NEXT: [[OUT:%.*]] = or disjoint i32 [[TMP0]], [[TMP1]]
2074
+ ; CHECK-NEXT: ret i32 [[OUT]]
2075
+ ;
2076
+ %bitop0 = and i32 %in , 2
2077
+ %out0 = mul i32 %bitop0 , 36
2078
+ %bitop1 = and i32 %in , 4
2079
+ %out1 = mul i32 %bitop1 , 72
2080
+ %out = or disjoint i32 %out0 , %out1
2081
+ ret i32 %out
2082
+ }
2083
+
2084
+ define i32 @or_combine_mul_and_diff_base (i32 %in , i32 %in1 ) {
2085
+ ; CHECK-LABEL: @or_combine_mul_and_diff_base(
2086
+ ; CHECK-NEXT: [[BITOP0:%.*]] = and i32 [[IN:%.*]], 2
2087
+ ; CHECK-NEXT: [[TMP0:%.*]] = mul nuw nsw i32 [[BITOP0]], 72
2088
+ ; CHECK-NEXT: [[BITOP1:%.*]] = and i32 [[IN1:%.*]], 4
2089
+ ; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i32 [[BITOP1]], 72
2090
+ ; CHECK-NEXT: [[OUT:%.*]] = or disjoint i32 [[TMP0]], [[TMP1]]
2091
+ ; CHECK-NEXT: ret i32 [[OUT]]
2092
+ ;
2093
+ %bitop0 = and i32 %in , 2
2094
+ %out0 = mul i32 %bitop0 , 72
2095
+ %bitop1 = and i32 %in1 , 4
2096
+ %out1 = mul i32 %bitop1 , 72
2097
+ %out = or disjoint i32 %out0 , %out1
2098
+ ret i32 %out
2099
+ }
2100
+
2101
+ define i32 @or_combine_mul_and_decomposed (i32 %in ) {
2102
+ ; CHECK-LABEL: @or_combine_mul_and_decomposed(
2103
+ ; CHECK-NEXT: [[TMP2:%.*]] = trunc i32 [[IN:%.*]] to i1
2104
+ ; CHECK-NEXT: [[OUT0:%.*]] = select i1 [[TMP2]], i32 72, i32 0
2105
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN]], 4
2106
+ ; CHECK-NEXT: [[OUT:%.*]] = mul nuw nsw i32 [[TMP1]], 72
2107
+ ; CHECK-NEXT: [[OUT1:%.*]] = or disjoint i32 [[OUT0]], [[OUT]]
2108
+ ; CHECK-NEXT: ret i32 [[OUT1]]
2109
+ ;
2110
+ %bitop0 = and i32 %in , 1
2111
+ %out0 = mul i32 %bitop0 , 72
2112
+ %bitop1 = and i32 %in , 4
2113
+ %out1 = mul i32 %bitop1 , 72
2114
+ %out = or disjoint i32 %out0 , %out1
2115
+ ret i32 %out
2116
+ }
0 commit comments