Skip to content

Commit 8e45bff

Browse files
authored
Rollup merge of #130268 - RalfJung:simd-shuffle-idx-vector, r=compiler-errors
simd_shuffle: require index argument to be a vector Remove some codegen hacks by forcing the SIMD shuffle `index` argument to be a vector, which means (thanks to rust-lang/rust#128537) that it will automatically be passed as an immediate in LLVM. The only special-casing we still have is for the extra sanity-checks we add that ensure that the indices are all in-bounds. (And the GCC backend needs to do a bunch of work since the Rust intrinsic is modeled after what LLVM expects, which seems to be quite different from what GCC expects.) Fixes rust-lang/rust#128738, see that issue for more context.
2 parents db89a0a + 6cd6ae3 commit 8e45bff

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

src/intrinsics/simd.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -664,15 +664,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
664664
let [left, right, index] = check_arg_count(args)?;
665665
let (left, left_len) = this.project_to_simd(left)?;
666666
let (right, right_len) = this.project_to_simd(right)?;
667+
let (index, index_len) = this.project_to_simd(index)?;
667668
let (dest, dest_len) = this.project_to_simd(dest)?;
668669

669-
// `index` is an array or a SIMD type
670-
let (index, index_len) = match index.layout.ty.kind() {
671-
// FIXME: remove this once `index` must always be a SIMD vector.
672-
ty::Array(..) => (index.clone(), index.len(this)?),
673-
_ => this.project_to_simd(index)?,
674-
};
675-
676670
assert_eq!(left_len, right_len);
677671
assert_eq!(index_len, dest_len);
678672

tests/pass/intrinsics/portable-simd.rs

-5
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ fn simd_intrinsics() {
619619
i32x4::from_array([10, 2, 10, 10])
620620
);
621621
assert_eq!(simd_shuffle_generic::<_, i32x4, { &[3, 1, 0, 2] }>(a, b), a,);
622-
assert_eq!(simd_shuffle::<_, _, i32x4>(a, b, const { [3u32, 1, 0, 2] }), a,);
623622
assert_eq!(
624623
simd_shuffle::<_, _, i32x4>(a, b, const { u32x4::from_array([3u32, 1, 0, 2]) }),
625624
a,
@@ -628,10 +627,6 @@ fn simd_intrinsics() {
628627
simd_shuffle_generic::<_, i32x4, { &[7, 5, 4, 6] }>(a, b),
629628
i32x4::from_array([4, 2, 1, 10]),
630629
);
631-
assert_eq!(
632-
simd_shuffle::<_, _, i32x4>(a, b, const { [7u32, 5, 4, 6] }),
633-
i32x4::from_array([4, 2, 1, 10]),
634-
);
635630
assert_eq!(
636631
simd_shuffle::<_, _, i32x4>(a, b, const { u32x4::from_array([7u32, 5, 4, 6]) }),
637632
i32x4::from_array([4, 2, 1, 10]),

0 commit comments

Comments
 (0)