编译以下内联程序集:
#![feature(portable_simd)]
use std::simd::{i64x8, f64x8};
use std::arch::asm;
pub fn convert(a: i64x8) -> f64x8{
let converted: f64x8;
unsafe {
asm!(
"vcvtqq2pd {converted} {a}",
a = in(zmm_reg) a,
converted = out(zmm_reg) converted,
);
}
converted
}
导致以下错误:
error: cannot use value of type `Simd<i64, 8>` for inline assembly
--> <source>:12:25
|
12 | a = in(zmm_reg) a,
| ^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
error: cannot use value of type `Simd<f64, 8>` for inline assembly
--> <source>:13:34
|
13 | converted = out(zmm_reg) converted,
| ^^^^^^^^^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
error: aborting due to 2 previous errors
您将需要-C target-feature=+avx512f
来编译以上内容.或者,请参阅this godbolt
这对我来说没有多大意义,因为inline assembly docs清楚地表明f64x8
和i64x8
是zmm_reg
可以接受的输入类型.
此外,错误消息指出SIMD向量是可接受的,但这就是我输入的内容.
如果与此相关,则将其转载到:
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.68.0-nightly (afaf3e07a 2023-01-14)
这是 rust 病还是我做错了什么?