Skip to content

Commit 4a69c8e

Browse files
committed
[InstCombine] add tests for demanded bit of mul; NFC
1 parent bc5644e commit 4a69c8e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

llvm/test/Transforms/InstCombine/mul-masked-bits.ll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,36 @@ define <4 x i1> @PR48683_vec_undef(<4 x i32> %x) {
5858
%c = icmp ne <4 x i32> %b, zeroinitializer
5959
ret <4 x i1> %c
6060
}
61+
62+
define i8 @one_demanded_bit(i8 %x) {
63+
; CHECK-LABEL: @one_demanded_bit(
64+
; CHECK-NEXT: [[M:%.*]] = mul i8 [[X:%.*]], -64
65+
; CHECK-NEXT: [[R:%.*]] = or i8 [[M]], -65
66+
; CHECK-NEXT: ret i8 [[R]]
67+
;
68+
%m = mul i8 %x, 192 ; 0b1100_0000
69+
%r = or i8 %m, 191 ; 0b1011_1111
70+
ret i8 %r
71+
}
72+
73+
define <2 x i8> @one_demanded_bit_splat(<2 x i8> %x) {
74+
; CHECK-LABEL: @one_demanded_bit_splat(
75+
; CHECK-NEXT: [[M:%.*]] = mul <2 x i8> [[X:%.*]], <i8 -96, i8 -96>
76+
; CHECK-NEXT: [[R:%.*]] = and <2 x i8> [[M]], <i8 32, i8 32>
77+
; CHECK-NEXT: ret <2 x i8> [[R]]
78+
;
79+
%m = mul <2 x i8> %x, <i8 160, i8 160> ; 0b1010_0000
80+
%r = and <2 x i8> %m, <i8 32, i8 32> ; 0b0010_0000
81+
ret <2 x i8> %r
82+
}
83+
84+
define i67 @one_demanded_low_bit(i67 %x) {
85+
; CHECK-LABEL: @one_demanded_low_bit(
86+
; CHECK-NEXT: [[M:%.*]] = mul i67 [[X:%.*]], -63
87+
; CHECK-NEXT: [[R:%.*]] = and i67 [[M]], 1
88+
; CHECK-NEXT: ret i67 [[R]]
89+
;
90+
%m = mul i67 %x, -63 ; any odd number will do
91+
%r = and i67 %m, 1
92+
ret i67 %r
93+
}

0 commit comments

Comments
 (0)