rust-lang / miri

An interpreter for Rust's mid-level intermediate representation
Apache License 2.0
4.18k stars 323 forks source link

Miri ICEs on non-power-of-2 non-packed SIMD vectors #3458

Closed RalfJung closed 1 month ago

RalfJung commented 3 months ago
#![feature(core_intrinsics)]
#![feature(repr_simd)]

use core::intrinsics::simd::*;

#[repr(simd)]
struct Simd<T, const N: usize>(pub [T; N]);

fn main() { unsafe {
    let v1 = Simd([1u32; 3]);
    let v2 = Simd([2u32; 3]);
    let v3 = simd_add(v1, v2);
    assert_eq!(v3.0, [3u32; 3]);
} }

Cc https://github.com/rust-lang/portable-simd/issues/319

RalfJung commented 1 month ago

With https://github.com/rust-lang/rust/pull/117116, there are now non-power-of-2 SIMD types without padding, and portable-simd is moving towards adopting those. They work fine in Miri. Only the variants that add padding lead to an ICE.

Currently it's unclear whether we'll even keep supporting them so this is pretty low priority on the Miri side.