You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
161
+
};
162
+
let a = codegen_operand(fx, a);
163
+
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8)
164
+
.expect("llvm.x86.avx.psrli.w imm8 not const");
165
+
166
+
simd_for_each_lane(fx, a, ret,&|fx, _lane_ty, _res_lane_ty, lane| match imm8
167
+
.try_to_bits(Size::from_bytes(4))
168
+
.unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8))
169
+
{
170
+
imm8 if imm8 < 16 => fx.bcx.ins().ushr_imm(lane, i64::from(imm8 asu8)),
171
+
_ => fx.bcx.ins().iconst(types::I32,0),
172
+
});
173
+
}
174
+
"llvm.x86.avx2.pslli.w" => {
175
+
let(a, imm8) = match args {
176
+
[a, imm8] => (a, imm8),
177
+
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
178
+
};
179
+
let a = codegen_operand(fx, a);
180
+
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8)
181
+
.expect("llvm.x86.avx.pslli.w imm8 not const");
182
+
183
+
simd_for_each_lane(fx, a, ret,&|fx, _lane_ty, _res_lane_ty, lane| match imm8
184
+
.try_to_bits(Size::from_bytes(4))
185
+
.unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8))
186
+
{
187
+
imm8 if imm8 < 16 => fx.bcx.ins().ishl_imm(lane, i64::from(imm8 asu8)),
188
+
_ => fx.bcx.ins().iconst(types::I32,0),
189
+
});
190
+
}
191
+
"llvm.x86.avx2.pshuf.b" => {
192
+
let(a, b) = match args {
193
+
[a, b] => (a, b),
194
+
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
195
+
};
196
+
let a = codegen_operand(fx, a);
197
+
let b = codegen_operand(fx, b);
198
+
199
+
// Based on the pseudocode at https://github.com/rust-lang/stdarch/blob/1cfbca8b38fd9b4282b2f054f61c6ca69fc7ce29/crates/core_arch/src/x86/avx2.rs#L2319-L2332
200
+
let zero = fx.bcx.ins().iconst(types::I8,0);
201
+
for i in0..16{
202
+
let b_lane = b.value_lane(fx, i).load_scalar(fx);
203
+
let is_zero = fx.bcx.ins().band_imm(b_lane,0x80);
204
+
let a_idx = fx.bcx.ins().band_imm(b_lane,0xf);
205
+
let a_idx = fx.bcx.ins().uextend(fx.pointer_type, a_idx);
206
+
let a_lane = a.value_lane_dyn(fx, a_idx).load_scalar(fx);
207
+
let res = fx.bcx.ins().select(is_zero, zero, a_lane);
0 commit comments