@@ -1159,3 +1159,39 @@ define i1 @two_types_of_bittest(i8 %x, i8 %c) {
1159
1159
%ret = and i1 %icmp1 , %icmp2
1160
1160
ret i1 %ret
1161
1161
}
1162
+
1163
+ define i1 @trunc_bittest_and_icmp_bittest (i8 %x , i8 %c ) {
1164
+ ; CHECK-LABEL: @trunc_bittest_and_icmp_bittest(
1165
+ ; CHECK-NEXT: [[T0:%.*]] = shl nuw i8 1, [[C:%.*]]
1166
+ ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
1167
+ ; CHECK-NEXT: [[AND:%.*]] = and i8 [[X]], [[T0]]
1168
+ ; CHECK-NEXT: [[ICMP2:%.*]] = icmp ne i8 [[AND]], 0
1169
+ ; CHECK-NEXT: [[RET:%.*]] = and i1 [[ICMP2]], [[TRUNC]]
1170
+ ; CHECK-NEXT: ret i1 [[RET]]
1171
+ ;
1172
+ %t0 = shl i8 1 , %c
1173
+ %trunc = trunc i8 %x to i1
1174
+ %and = and i8 %x , %t0
1175
+ %icmp2 = icmp ne i8 %and , 0
1176
+ %ret = and i1 %trunc , %icmp2
1177
+ ret i1 %ret
1178
+ }
1179
+
1180
+ define i1 @trunc_bittest_or_icmp_bittest (i8 %x , i8 %c ) {
1181
+ ; CHECK-LABEL: @trunc_bittest_or_icmp_bittest(
1182
+ ; CHECK-NEXT: [[T0:%.*]] = shl nuw i8 1, [[C:%.*]]
1183
+ ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
1184
+ ; CHECK-NEXT: [[AND:%.*]] = and i8 [[X]], [[T0]]
1185
+ ; CHECK-NEXT: [[ICMP2:%.*]] = icmp eq i8 [[AND]], 0
1186
+ ; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[TRUNC]], true
1187
+ ; CHECK-NEXT: [[RET:%.*]] = or i1 [[ICMP2]], [[NOT]]
1188
+ ; CHECK-NEXT: ret i1 [[RET]]
1189
+ ;
1190
+ %t0 = shl i8 1 , %c
1191
+ %trunc = trunc i8 %x to i1
1192
+ %and = and i8 %x , %t0
1193
+ %icmp2 = icmp eq i8 %and , 0
1194
+ %not = xor i1 %trunc , true
1195
+ %ret = or i1 %not , %icmp2
1196
+ ret i1 %ret
1197
+ }
0 commit comments