1
Fork 0

Evaluate constants in SIMD vec lengths before rejecting them

This commit is contained in:
Oli Scherer 2024-12-09 10:06:51 +00:00
parent c04b52ae9e
commit 6d3d61f1b0
3 changed files with 2 additions and 11 deletions

View file

@ -83,6 +83,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
let (size, ty) = match elem_ty.kind() {
ty::Array(ty, len) => {
let len = self.tcx.normalize_erasing_regions(self.typing_env, *len);
if let Some(len) = len.try_to_target_usize(self.tcx) {
(len, *ty)
} else {

View file

@ -2,6 +2,7 @@
//! SIMD vector length constants instead of assuming they are literals.
//@ only-x86_64
//@ check-pass
#![feature(repr_simd)]
@ -15,7 +16,6 @@ pub unsafe fn foo(a: Foo) {
std::arch::asm!(
"movaps {src}, {src}",
src = in(xmm_reg) a,
//~^ ERROR: cannot use value of type `Foo` for inline assembly
);
}

View file

@ -1,10 +0,0 @@
error: cannot use value of type `Foo` for inline assembly
--> $DIR/named_const_simd_vec_len.rs:17:27
|
LL | src = in(xmm_reg) a,
| ^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
error: aborting due to 1 previous error