Skip to content

Commit 027a105

Browse files
Rollup merge of rust-lang#129696 - RalfJung:stdarch, r=Amanieu
update stdarch The goal is mostly to pull in rust-lang/stdarch#1633. r? `@Amanieu`
2 parents 47b5185 + 542a6c6 commit 027a105

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/tools/miri/src/intrinsics/simd.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -666,22 +666,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
666666
let (right, right_len) = this.operand_to_simd(right)?;
667667
let (dest, dest_len) = this.mplace_to_simd(dest)?;
668668

669-
// `index` is an array, not a SIMD type
670-
let ty::Array(_, index_len) = index.layout.ty.kind() else {
671-
span_bug!(
672-
this.cur_span(),
673-
"simd_shuffle index argument has non-array type {}",
674-
index.layout.ty
675-
)
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.assert_mem_place(), index.len(this)?),
673+
_ => this.operand_to_simd(index)?,
676674
};
677-
let index_len = index_len.eval_target_usize(*this.tcx, this.param_env());
678675

679676
assert_eq!(left_len, right_len);
680677
assert_eq!(index_len, dest_len);
681678

682679
for i in 0..dest_len {
683680
let src_index: u64 = this
684-
.read_immediate(&this.project_index(index, i)?)?
681+
.read_immediate(&this.project_index(&index, i)?)?
685682
.to_scalar()
686683
.to_u32()?
687684
.into();

src/tools/miri/tests/pass/intrinsics/portable-simd.rs

+8
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,10 @@ fn simd_intrinsics() {
620620
);
621621
assert_eq!(simd_shuffle_generic::<_, i32x4, { &[3, 1, 0, 2] }>(a, b), a,);
622622
assert_eq!(simd_shuffle::<_, _, i32x4>(a, b, const { [3u32, 1, 0, 2] }), a,);
623+
assert_eq!(
624+
simd_shuffle::<_, _, i32x4>(a, b, const { u32x4::from_array([3u32, 1, 0, 2]) }),
625+
a,
626+
);
623627
assert_eq!(
624628
simd_shuffle_generic::<_, i32x4, { &[7, 5, 4, 6] }>(a, b),
625629
i32x4::from_array([4, 2, 1, 10]),
@@ -628,6 +632,10 @@ fn simd_intrinsics() {
628632
simd_shuffle::<_, _, i32x4>(a, b, const { [7u32, 5, 4, 6] }),
629633
i32x4::from_array([4, 2, 1, 10]),
630634
);
635+
assert_eq!(
636+
simd_shuffle::<_, _, i32x4>(a, b, const { u32x4::from_array([7u32, 5, 4, 6]) }),
637+
i32x4::from_array([4, 2, 1, 10]),
638+
);
631639
}
632640
}
633641

0 commit comments

Comments
 (0)