Skip to content

Commit e4d0811

Browse files
committed
Implement _mm_srli_epi16 and _mm_slli_epi16
1 parent f36bb6d commit e4d0811

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/intrinsics/llvm_x86.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,40 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
120120
_ => fx.bcx.ins().iconst(types::I32, 0),
121121
});
122122
}
123+
"llvm.x86.sse2.psrli.w" => {
124+
let (a, imm8) = match args {
125+
[a, imm8] => (a, imm8),
126+
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
127+
};
128+
let a = codegen_operand(fx, a);
129+
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8)
130+
.expect("llvm.x86.sse2.psrli.d imm8 not const");
131+
132+
simd_for_each_lane(fx, a, ret, &|fx, _lane_ty, _res_lane_ty, lane| match imm8
133+
.try_to_bits(Size::from_bytes(4))
134+
.unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8))
135+
{
136+
imm8 if imm8 < 16 => fx.bcx.ins().ushr_imm(lane, i64::from(imm8 as u8)),
137+
_ => fx.bcx.ins().iconst(types::I32, 0),
138+
});
139+
}
140+
"llvm.x86.sse2.pslli.w" => {
141+
let (a, imm8) = match args {
142+
[a, imm8] => (a, imm8),
143+
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
144+
};
145+
let a = codegen_operand(fx, a);
146+
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8)
147+
.expect("llvm.x86.sse2.pslli.d imm8 not const");
148+
149+
simd_for_each_lane(fx, a, ret, &|fx, _lane_ty, _res_lane_ty, lane| match imm8
150+
.try_to_bits(Size::from_bytes(4))
151+
.unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8))
152+
{
153+
imm8 if imm8 < 16 => fx.bcx.ins().ishl_imm(lane, i64::from(imm8 as u8)),
154+
_ => fx.bcx.ins().iconst(types::I32, 0),
155+
});
156+
}
123157
"llvm.x86.avx.psrli.d" => {
124158
let (a, imm8) = match args {
125159
[a, imm8] => (a, imm8),

0 commit comments

Comments
 (0)