Skip to content

Commit d6c8e0f

Browse files
committed
simd_shuffle intrinsic: allow argument to be passed as vector (not just as array)
1 parent 13e7329 commit d6c8e0f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/intrinsic/simd.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,24 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
353353
}
354354

355355
if name == sym::simd_shuffle {
356-
// Make sure this is actually an array, since typeck only checks the length-suffixed
356+
// Make sure this is actually an array or SIMD vector, since typeck only checks the length-suffixed
357357
// version of this intrinsic.
358-
let n: u64 = match *args[2].layout.ty.kind() {
358+
let idx_ty = args[2].layout.ty;
359+
let n: u64 = match idx_ty.kind() {
359360
ty::Array(ty, len) if matches!(*ty.kind(), ty::Uint(ty::UintTy::U32)) => {
360361
len.try_eval_target_usize(bx.cx.tcx, ty::ParamEnv::reveal_all()).unwrap_or_else(
361362
|| span_bug!(span, "could not evaluate shuffle index array length"),
362363
)
363364
}
364-
_ => return_error!(InvalidMonomorphization::SimdShuffle {
365-
span,
366-
name,
367-
ty: args[2].layout.ty
368-
}),
365+
_ if idx_ty.is_simd()
366+
&& matches!(
367+
idx_ty.simd_size_and_type(bx.cx.tcx).1.kind(),
368+
ty::Uint(ty::UintTy::U32)
369+
) =>
370+
{
371+
idx_ty.simd_size_and_type(bx.cx.tcx).0
372+
}
373+
_ => return_error!(InvalidMonomorphization::SimdShuffle { span, name, ty: idx_ty }),
369374
};
370375
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
371376

0 commit comments

Comments
 (0)