Skip to content

Commit ad8bf89

Browse files
committed
interpret: do not ICE on padded non-pow2 SIMD vectors
1 parent 4e410a9 commit ad8bf89

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/pass/intrinsics/portable-simd.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@compile-flags: -Zmiri-strict-provenance
2-
#![feature(portable_simd, adt_const_params, core_intrinsics)]
2+
#![feature(portable_simd, adt_const_params, core_intrinsics, repr_simd)]
33
#![allow(incomplete_features, internal_features)]
44
use std::intrinsics::simd as intrinsics;
55
use std::ptr;
@@ -581,11 +581,32 @@ fn simd_masked_loadstore() {
581581
assert_eq!(buf, [2, 3, 4]);
582582
}
583583

584+
fn simd_ops_non_pow2() {
585+
// Just a little smoke test for operations on non-power-of-two vectors.
586+
#[repr(simd, packed)]
587+
#[derive(Copy, Clone)]
588+
pub struct SimdPacked<T, const N: usize>([T; N]);
589+
#[repr(simd)]
590+
#[derive(Copy, Clone)]
591+
pub struct SimdPadded<T, const N: usize>([T; N]);
592+
593+
let x = SimdPacked([1u32; 3]);
594+
let y = SimdPacked([2u32; 3]);
595+
let z = unsafe { intrinsics::simd_add(x, y) };
596+
assert_eq!({ z.0 }, [3u32; 3]);
597+
598+
let x = SimdPadded([1u32; 3]);
599+
let y = SimdPadded([2u32; 3]);
600+
let z = unsafe { intrinsics::simd_add(x, y) };
601+
assert_eq!(z.0, [3u32; 3]);
602+
}
603+
584604
fn main() {
585605
simd_mask();
586606
simd_ops_f32();
587607
simd_ops_f64();
588608
simd_ops_i32();
609+
simd_ops_non_pow2();
589610
simd_cast();
590611
simd_swizzle();
591612
simd_gather_scatter();

0 commit comments

Comments
 (0)