Skip to content

Commit 51f8574

Browse files
authored
Rollup merge of #126184 - RalfJung:interpret-simd-nonpow2, r=oli-obk
interpret: do not ICE on padded non-pow2 SIMD vectors Fixes #3458 r? ``@oli-obk``
2 parents 334a205 + ad8bf89 commit 51f8574

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/pass/intrinsics/portable-simd.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,32 @@ fn simd_masked_loadstore() {
658658
assert_eq!(buf, [2, 3, 4]);
659659
}
660660

661+
fn simd_ops_non_pow2() {
662+
// Just a little smoke test for operations on non-power-of-two vectors.
663+
#[repr(simd, packed)]
664+
#[derive(Copy, Clone)]
665+
pub struct SimdPacked<T, const N: usize>([T; N]);
666+
#[repr(simd)]
667+
#[derive(Copy, Clone)]
668+
pub struct SimdPadded<T, const N: usize>([T; N]);
669+
670+
let x = SimdPacked([1u32; 3]);
671+
let y = SimdPacked([2u32; 3]);
672+
let z = unsafe { intrinsics::simd_add(x, y) };
673+
assert_eq!({ z.0 }, [3u32; 3]);
674+
675+
let x = SimdPadded([1u32; 3]);
676+
let y = SimdPadded([2u32; 3]);
677+
let z = unsafe { intrinsics::simd_add(x, y) };
678+
assert_eq!(z.0, [3u32; 3]);
679+
}
680+
661681
fn main() {
662682
simd_mask();
663683
simd_ops_f32();
664684
simd_ops_f64();
665685
simd_ops_i32();
686+
simd_ops_non_pow2();
666687
simd_cast();
667688
simd_swizzle();
668689
simd_gather_scatter();

0 commit comments

Comments
 (0)