Rollup merge of #138940 - sayantn:stabilize-avx512, r=Amanieu,traviscross

Stabilize the avx512 target features

This PR stabilizes the AVX512 target features - see [this comment](https://github.com/rust-lang/rust/issues/111137#issuecomment-2745821279).

Tracking Issue - #44839

The target feature UI tests have been changed to `x87` (chosen because this is very unlikely to stablize ever, please comment if some other feature will be better)

related: #111137
This commit is contained in:
León Orell Valerian Liehr 2025-05-18 18:44:10 +02:00 committed by GitHub
commit 2f6811eff8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 54 additions and 64 deletions

View file

@ -82,6 +82,8 @@ declare_features! (
(accepted, attr_literals, "1.30.0", Some(34981)),
/// Allows overloading augmented assignment operations like `a += b`.
(accepted, augmented_assignments, "1.8.0", Some(28235)),
/// Allows using `avx512*` target features.
(accepted, avx512_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)),
/// Allows mixing bind-by-move in patterns and references to those identifiers in guards.
(accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287)),
/// Allows bindings in the subpattern of a binding pattern.

View file

@ -318,7 +318,6 @@ declare_features! (
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
(unstable, apx_target_feature, "1.88.0", Some(139284)),
(unstable, arm_target_feature, "1.27.0", Some(44839)),
(unstable, avx512_target_feature, "1.27.0", Some(44839)),
(unstable, bpf_target_feature, "1.54.0", Some(44839)),
(unstable, csky_target_feature, "1.73.0", Some(44839)),
(unstable, ermsb_target_feature, "1.49.0", Some(44839)),

View file

@ -416,25 +416,25 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
),
("avx10.2", Unstable(sym::avx10_target_feature), &["avx10.1"]),
("avx2", Stable, &["avx"]),
("avx512bf16", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512bitalg", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512bw", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512cd", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512dq", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512f", Unstable(sym::avx512_target_feature), &["avx2", "fma", "f16c"]),
("avx512fp16", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512ifma", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vbmi", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512vbmi2", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512vl", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vnni", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vp2intersect", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vpopcntdq", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avxifma", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxneconvert", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxvnni", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxvnniint16", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxvnniint8", Unstable(sym::avx512_target_feature), &["avx2"]),
("avx512bf16", Stable, &["avx512bw"]),
("avx512bitalg", Stable, &["avx512bw"]),
("avx512bw", Stable, &["avx512f"]),
("avx512cd", Stable, &["avx512f"]),
("avx512dq", Stable, &["avx512f"]),
("avx512f", Stable, &["avx2", "fma", "f16c"]),
("avx512fp16", Stable, &["avx512bw"]),
("avx512ifma", Stable, &["avx512f"]),
("avx512vbmi", Stable, &["avx512bw"]),
("avx512vbmi2", Stable, &["avx512bw"]),
("avx512vl", Stable, &["avx512f"]),
("avx512vnni", Stable, &["avx512f"]),
("avx512vp2intersect", Stable, &["avx512f"]),
("avx512vpopcntdq", Stable, &["avx512f"]),
("avxifma", Stable, &["avx2"]),
("avxneconvert", Stable, &["avx2"]),
("avxvnni", Stable, &["avx2"]),
("avxvnniint16", Stable, &["avx2"]),
("avxvnniint8", Stable, &["avx2"]),
("bmi1", Stable, &[]),
("bmi2", Stable, &[]),
("cmpxchg16b", Stable, &[]),
@ -442,7 +442,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("f16c", Stable, &["avx"]),
("fma", Stable, &["avx"]),
("fxsr", Stable, &[]),
("gfni", Unstable(sym::avx512_target_feature), &["sse2"]),
("gfni", Stable, &["sse2"]),
("kl", Unstable(sym::keylocker_x86), &["sse2"]),
("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
("lzcnt", Stable, &[]),
@ -469,8 +469,8 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("sse4a", Unstable(sym::sse4a_target_feature), &["sse3"]),
("ssse3", Stable, &["sse3"]),
("tbm", Unstable(sym::tbm_target_feature), &[]),
("vaes", Unstable(sym::avx512_target_feature), &["avx2", "aes"]),
("vpclmulqdq", Unstable(sym::avx512_target_feature), &["avx", "pclmulqdq"]),
("vaes", Stable, &["avx2", "aes"]),
("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
("widekl", Unstable(sym::keylocker_x86), &["kl"]),
("x87", Unstable(sym::x87_target_feature), &[]),
("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]),

View file

@ -187,9 +187,9 @@
//
// Target features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(avx512_target_feature))]
#![feature(aarch64_unstable_target_feature)]
#![feature(arm_target_feature)]
#![feature(avx512_target_feature)]
#![feature(hexagon_target_feature)]
#![feature(keylocker_x86)]
#![feature(loongarch_target_feature)]

@ -1 +1 @@
Subproject commit f1c1839c0deb985a9f98cbd6b38a6d43f2df6157
Subproject commit 1dfaa4db2479753a46a3e90f2c3c89d89d0b21f1

View file

@ -2,7 +2,7 @@
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=+aes,+vaes,+avx512f
#![feature(avx512_target_feature, stdarch_x86_avx512)]
#![feature(stdarch_x86_avx512)]
use core::mem::transmute;
#[cfg(target_arch = "x86")]

View file

@ -2,7 +2,6 @@
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bitalg,+avx512vpopcntdq
#![feature(avx512_target_feature)]
#![feature(stdarch_x86_avx512)]
#[cfg(target_arch = "x86")]

View file

@ -6,7 +6,6 @@
// be interpreted as integers; signedness does not make sense for them, but
// __mXXXi happens to be defined in terms of signed integers.
#![allow(overflowing_literals)]
#![feature(avx512_target_feature)]
#![feature(stdarch_x86_avx512)]
#[cfg(target_arch = "x86")]

View file

@ -8,7 +8,6 @@
// be interpreted as integers; signedness does not make sense for them, but
// __mXXXi happens to be defined in terms of signed integers.
#![allow(overflowing_literals)]
#![feature(avx512_target_feature)]
#![feature(stdarch_x86_avx512)]
#[cfg(target_arch = "x86")]

View file

@ -7,8 +7,6 @@
//@ run-pass
//@ needs-subprocess
#![feature(avx512_target_feature)]
#![allow(overflowing_literals)]
#![allow(unused_variables)]

View file

@ -2,7 +2,6 @@
//@ build-fail
//@ compile-flags: -C target-feature=-avx
#![feature(avx512_target_feature)]
#![feature(portable_simd)]
#![feature(simd_ffi)]
#![allow(improper_ctypes_definitions)]

View file

@ -1,5 +1,5 @@
error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:60:11
--> $DIR/simd-abi-checks-avx.rs:59:11
|
LL | f(g());
| ^^^ function called here
@ -7,7 +7,7 @@ LL | f(g());
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:60:9
--> $DIR/simd-abi-checks-avx.rs:59:9
|
LL | f(g());
| ^^^^^^ function called here
@ -15,7 +15,7 @@ LL | f(g());
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:66:14
--> $DIR/simd-abi-checks-avx.rs:65:14
|
LL | gavx(favx());
| ^^^^^^ function called here
@ -23,7 +23,7 @@ LL | gavx(favx());
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:66:9
--> $DIR/simd-abi-checks-avx.rs:65:9
|
LL | gavx(favx());
| ^^^^^^^^^^^^ function called here
@ -31,7 +31,7 @@ LL | gavx(favx());
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:76:19
--> $DIR/simd-abi-checks-avx.rs:75:19
|
LL | w(Wrapper(g()));
| ^^^ function called here
@ -39,7 +39,7 @@ LL | w(Wrapper(g()));
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:76:9
--> $DIR/simd-abi-checks-avx.rs:75:9
|
LL | w(Wrapper(g()));
| ^^^^^^^^^^^^^^^ function called here
@ -47,7 +47,7 @@ LL | w(Wrapper(g()));
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:90:9
--> $DIR/simd-abi-checks-avx.rs:89:9
|
LL | some_extern();
| ^^^^^^^^^^^^^ function called here
@ -55,7 +55,7 @@ LL | some_extern();
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled
--> $DIR/simd-abi-checks-avx.rs:25:1
--> $DIR/simd-abi-checks-avx.rs:24:1
|
LL | unsafe extern "C" fn g() -> __m256 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
@ -63,7 +63,7 @@ LL | unsafe extern "C" fn g() -> __m256 {
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled
--> $DIR/simd-abi-checks-avx.rs:20:1
--> $DIR/simd-abi-checks-avx.rs:19:1
|
LL | unsafe extern "C" fn f(_: __m256) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
@ -71,7 +71,7 @@ LL | unsafe extern "C" fn f(_: __m256) {
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled
--> $DIR/simd-abi-checks-avx.rs:15:1
--> $DIR/simd-abi-checks-avx.rs:14:1
|
LL | unsafe extern "C" fn w(_: Wrapper) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
@ -79,7 +79,7 @@ LL | unsafe extern "C" fn w(_: Wrapper) {
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:54:8
--> $DIR/simd-abi-checks-avx.rs:53:8
|
LL | || g()
| ^^^ function called here
@ -87,7 +87,7 @@ LL | || g()
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
note: the above error was encountered while instantiating `fn in_closure::{closure#0}`
--> $DIR/simd-abi-checks-avx.rs:82:9
--> $DIR/simd-abi-checks-avx.rs:81:9
|
LL | in_closure()();
| ^^^^^^^^^^^^^^

View file

@ -2,7 +2,6 @@
//@ only-x86_64
//@ compile-flags: --crate-type=lib -C target-cpu=skylake
#![feature(avx512_target_feature)]
#![feature(stdarch_x86_avx512)]
use std::arch::x86_64::*;

View file

@ -2,8 +2,6 @@
// Set the base cpu explicitly, in case the default has been changed.
//@ compile-flags: -C target-cpu=x86-64
#![feature(avx512_target_feature)]
use std::arch::asm;
#[target_feature(enable = "avx")]

View file

@ -1,23 +1,23 @@
error: register class `ymm_reg` requires the `avx` target feature
--> $DIR/target-feature-attr.rs:20:40
--> $DIR/target-feature-attr.rs:18:40
|
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
| ^^^^^^^^^^^^^
error: register class `ymm_reg` requires the `avx` target feature
--> $DIR/target-feature-attr.rs:20:55
--> $DIR/target-feature-attr.rs:18:55
|
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
| ^^^^^^^^^^^^^
error: register class `ymm_reg` requires the `avx` target feature
--> $DIR/target-feature-attr.rs:20:70
--> $DIR/target-feature-attr.rs:18:70
|
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
| ^^^^^^^^^^^^^^^^^^
error: register class `kreg` requires at least one of the following target features: avx512bw, avx512f
--> $DIR/target-feature-attr.rs:35:23
--> $DIR/target-feature-attr.rs:33:23
|
LL | asm!("/* {0} */", in(kreg) x);
| ^^^^^^^^^^

View file

@ -7,7 +7,6 @@
//@ ignore-fuchsia must translate zircon signal to SIGILL, FIXME (#58590)
#![feature(repr_simd, target_feature, cfg_target_feature)]
#![feature(avx512_target_feature)]
use std::process::{Command, ExitStatus};
use std::env;

View file

@ -1,5 +1,5 @@
#![feature(avx512_target_feature)]
#![feature(x87_target_feature)]
#[inline]
#[target_feature(enable = "avx512ifma")]
#[target_feature(enable = "x87")]
pub unsafe fn foo() {}

View file

@ -2,7 +2,6 @@
//
// gate-test-sse4a_target_feature
// gate-test-powerpc_target_feature
// gate-test-avx512_target_feature
// gate-test-tbm_target_feature
// gate-test-arm_target_feature
// gate-test-hexagon_target_feature
@ -27,7 +26,7 @@
// gate-test-x87_target_feature
// gate-test-m68k_target_feature
#[target_feature(enable = "avx512bw")]
#[target_feature(enable = "x87")]
//~^ ERROR: currently unstable
unsafe fn foo() {}

View file

@ -1,11 +1,11 @@
error[E0658]: the target feature `avx512bw` is currently unstable
--> $DIR/gate.rs:30:18
error[E0658]: the target feature `x87` is currently unstable
--> $DIR/gate.rs:29:18
|
LL | #[target_feature(enable = "avx512bw")]
| ^^^^^^^^^^^^^^^^^^^
LL | #[target_feature(enable = "x87")]
| ^^^^^^^^^^^^^^
|
= note: see issue #44839 <https://github.com/rust-lang/rust/issues/44839> for more information
= help: add `#![feature(avx512_target_feature)]` to the crate attributes to enable
= help: add `#![feature(x87_target_feature)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error

View file

@ -1,8 +1,8 @@
//@ compile-flags: -Ctarget-feature=+vaes --crate-type=rlib --target=x86_64-unknown-linux-gnu
//@ compile-flags: -Ctarget-feature=+x87 --crate-type=rlib --target=x86_64-unknown-linux-gnu
//@ build-pass
//@ needs-llvm-components: x86
#![feature(no_core)]
#![no_core]
//~? WARN unstable feature specified for `-Ctarget-feature`: `vaes`
//~? WARN unstable feature specified for `-Ctarget-feature`: `x87`

View file

@ -1,4 +1,4 @@
warning: unstable feature specified for `-Ctarget-feature`: `vaes`
warning: unstable feature specified for `-Ctarget-feature`: `x87`
|
= note: this feature is not stably supported; its behavior can change in the future