Implicitly enable evex512 if avx512 is enabled · rust-lang/rust@369fff6 (original) (raw)
File tree
2 files changed
lines changed
- compiler/rustc_codegen_llvm/src
2 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -266,6 +266,10 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> { | ||
| 266 | 266 | ("riscv32" | "riscv64", "fast-unaligned-access") if get_version().0 <= 17 => { |
| 267 | 267 | LLVMFeature::new("unaligned-scalar-mem") |
| 268 | 268 | } |
| 269 | +// For LLVM 18, enable the evex512 target feature if a avx512 target feature is enabled. | |
| 270 | +("x86", s) if get_version().0 >= 18 && s.starts_with("avx512") => { | |
| 271 | +LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")) | |
| 272 | +} | |
| 269 | 273 | (_, s) => LLVMFeature::new(s), |
| 270 | 274 | } |
| 271 | 275 | } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| 1 | +// build-pass | |
| 2 | +// only-x86_64 | |
| 3 | +// compile-flags: --crate-type=lib -C target-cpu=skylake | |
| 4 | + | |
| 5 | +#![feature(avx512_target_feature)] | |
| 6 | +#![feature(stdarch_x86_avx512)] | |
| 7 | + | |
| 8 | +use std::arch::x86_64::*; | |
| 9 | + | |
| 10 | +#[target_feature(enable = "avx512f")] | |
| 11 | +#[no_mangle] | |
| 12 | +pub unsafe fn test(res: *mut f64, p: *const f64) { | |
| 13 | +let arg = _mm512_load_pd(p); | |
| 14 | +_mm512_store_pd(res, _mm512_fmaddsub_pd(arg, arg, arg)); | |
| 15 | +} |