Skip to content

Commit 8a26d21

Browse files
authored
Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee
simd_shuffle intrinsic: allow argument to be passed as vector See rust-lang/rust#128738 for context. I'd like to get rid of [this hack](https://github.com/rust-lang/rust/blob/6c0b89dfac65be9a5be12f938f23098ebc36c635/compiler/rustc_codegen_ssa/src/mir/block.rs#L922-L935). rust-lang/rust#128537 almost lets us do that since constant SIMD vectors will then be passed as immediate arguments. However, simd_shuffle for some reason actually takes an *array* as argument, not a vector, so the hack is still required to ensure that the array becomes an immediate (which then later stages of codegen convert into a vector, as that's what LLVM needs). This PR prepares simd_shuffle to also support a vector as the `idx` argument. Once this lands, stdarch can hopefully be updated to pass `idx` as a vector, and then support for arrays can be removed, which finally lets us get rid of that hack.
2 parents 8e7b3b5 + 6906793 commit 8a26d21

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/intrinsics/simd.rs

+10
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
191191
})
192192
.try_into()
193193
.unwrap(),
194+
_ if idx_ty.is_simd()
195+
&& matches!(
196+
idx_ty.simd_size_and_type(fx.tcx).1.kind(),
197+
ty::Uint(ty::UintTy::U32)
198+
) =>
199+
{
200+
idx_ty.simd_size_and_type(fx.tcx).0.try_into().unwrap()
201+
}
194202
_ => {
195203
fx.tcx.dcx().span_err(
196204
span,
@@ -213,6 +221,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
213221

214222
let total_len = lane_count * 2;
215223

224+
// FIXME: this is a terrible abstraction-breaking hack.
225+
// Find a way to reuse `immediate_const_vector` from `codegen_ssa` instead.
216226
let indexes = {
217227
use rustc_middle::mir::interpret::*;
218228
let idx_const = match &idx.node {

0 commit comments

Comments
 (0)