Skip to content

Commit 4d0e990

Browse files
author
Macsen Casaus
committed
pre-commit test
1 parent 64704c6 commit 4d0e990

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

llvm/test/Transforms/InstCombine/known-bits.ll

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,62 @@ define i1 @extract_value_smul_fail(i8 %xx, i8 %yy) {
12441244
ret i1 %r
12451245
}
12461246

1247+
define i8 @known_self_mul_bit_0_set(i8 noundef %x) {
1248+
; CHECK-LABEL: @known_self_mul_bit_0_set(
1249+
; CHECK-NEXT: [[BIT_0_SET:%.*]] = or i8 [[X:%.*]], 1
1250+
; CHECK-NEXT: [[SELF_MUL:%.*]] = mul i8 [[BIT_0_SET]], [[BIT_0_SET]]
1251+
; CHECK-NEXT: [[R:%.*]] = and i8 [[SELF_MUL]], 4
1252+
; CHECK-NEXT: ret i8 [[R]]
1253+
;
1254+
%bit_0_set = or i8 %x, 1
1255+
%self_mul = mul i8 %bit_0_set, %bit_0_set
1256+
%r = and i8 %self_mul, 4
1257+
ret i8 %r
1258+
}
1259+
1260+
define i8 @known_self_mul_bit_0_unset(i8 noundef %x) {
1261+
; CHECK-LABEL: @known_self_mul_bit_0_unset(
1262+
; CHECK-NEXT: [[BIT_0_UNSET:%.*]] = and i8 [[X:%.*]], -2
1263+
; CHECK-NEXT: [[SELF_MUL:%.*]] = mul i8 [[BIT_0_UNSET]], [[BIT_0_UNSET]]
1264+
; CHECK-NEXT: [[R:%.*]] = and i8 [[SELF_MUL]], 8
1265+
; CHECK-NEXT: ret i8 [[R]]
1266+
;
1267+
%bit_0_unset = and i8 %x, -2
1268+
%self_mul = mul i8 %bit_0_unset, %bit_0_unset
1269+
%r = and i8 %self_mul, 8
1270+
ret i8 %r
1271+
}
1272+
1273+
define i8 @known_self_mul_bit_1_set_bit_0_unset(i8 noundef %x) {
1274+
; CHECK-LABEL: @known_self_mul_bit_1_set_bit_0_unset(
1275+
; CHECK-NEXT: [[LOWER_2_UNSET:%.*]] = and i8 [[X:%.*]], -4
1276+
; CHECK-NEXT: [[BIT_1_SET_BIT_0_UNSET:%.*]] = or disjoint i8 [[LOWER_2_UNSET]], 2
1277+
; CHECK-NEXT: [[SELF_MUL:%.*]] = mul i8 [[BIT_1_SET_BIT_0_UNSET]], [[BIT_1_SET_BIT_0_UNSET]]
1278+
; CHECK-NEXT: [[R:%.*]] = and i8 [[SELF_MUL]], 24
1279+
; CHECK-NEXT: ret i8 [[R]]
1280+
;
1281+
%lower_2_unset = and i8 %x, -4
1282+
%bit_1_set_bit_0_unset = or disjoint i8 %lower_2_unset, 2
1283+
%self_mul = mul i8 %bit_1_set_bit_0_unset, %bit_1_set_bit_0_unset
1284+
%r = and i8 %self_mul, 24
1285+
ret i8 %r
1286+
}
1287+
1288+
define i4 @known_self_mul_bit_1_set_bit_0_unset_i4(i4 noundef %x) {
1289+
; CHECK-LABEL: @known_self_mul_bit_1_set_bit_0_unset_i4(
1290+
; CHECK-NEXT: [[LOWER_2_UNSET:%.*]] = and i4 [[X:%.*]], -4
1291+
; CHECK-NEXT: [[BIT_1_SET_BIT_0_UNSET:%.*]] = or disjoint i4 [[LOWER_2_UNSET]], 2
1292+
; CHECK-NEXT: [[SELF_MUL:%.*]] = mul i4 [[BIT_1_SET_BIT_0_UNSET]], [[BIT_1_SET_BIT_0_UNSET]]
1293+
; CHECK-NEXT: [[R:%.*]] = and i4 [[SELF_MUL]], -8
1294+
; CHECK-NEXT: ret i4 [[R]]
1295+
;
1296+
%lower_2_unset = and i4 %x, -4
1297+
%bit_1_set_bit_0_unset = or disjoint i4 %lower_2_unset, 2
1298+
%self_mul = mul i4 %bit_1_set_bit_0_unset, %bit_1_set_bit_0_unset
1299+
%r = and i4 %self_mul, 24
1300+
ret i4 %r
1301+
}
1302+
12471303
define i8 @known_reduce_or(<2 x i8> %xx) {
12481304
; CHECK-LABEL: @known_reduce_or(
12491305
; CHECK-NEXT: ret i8 1

0 commit comments

Comments
 (0)