Open
Description
This is basically #105439 again. I'm assigning this to me because I think we should just ban it instead of making it work -- it's always problematic because vectors want to be immediates, but indexing wants things in-memory, so it'd be better to require insert
/extract
element on immediates.
EDIT: MCP to deem this unsupported rust-lang/compiler-team#838
Demo: https://rust.godbolt.org/z/Mr5edjzM9
#[inline(always)]
fn to_array3(a: i32x3) -> [i32; 3] {
a.0
}
#[no_mangle]
pub fn simd_add_self_then_return_array_packed(a: i32x3) -> [i32; 3] {
let b = unsafe { core::intrinsics::simd::simd_add(a, a) };
to_array3(b)
}
Resulting IR on rustc 1.86.0-nightly (a567209 2025-02-13)
define void @simd_add_self_then_return_array_packed(ptr dead_on_unwind noalias nocapture noundef writable writeonly sret([12 x i8]) align 4 dereferenceable(12) %_0, ptr noalias nocapture noundef readonly align 16 dereferenceable(16) %a) unnamed_addr {
start:
%0 = load i32, ptr %a, align 16
%1 = shl i32 %0, 1
store i32 %1, ptr %_0, align 4
ret void
}
which is clearly wrong, since it only set one of the three i32
s in the result array.