Skip to content

Stabilize the avx512 target features #138940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ declare_features! (
(unstable, aarch64_unstable_target_feature, "1.82.0", Some(44839)),
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
(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)),
Expand Down
44 changes: 22 additions & 22 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,33 +392,33 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("amx-transpose", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
("avx", Stable, &["sse4.2"]),
("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", "avx512vl", "avx512dq"]),
("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", "avx512vl", "avx512dq"]),
("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, &[]),
("ermsb", Unstable(sym::ermsb_target_feature), &[]),
("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, &[]),
Expand All @@ -445,8 +445,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"]),
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/shims/x86/intrinsics-x86-gfni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/abi/homogenous-floats-target-feature-mixup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//@ run-pass
//@ needs-subprocess

#![feature(avx512_target_feature)]

#![allow(overflowing_literals)]
#![allow(unused_variables)]

Expand Down
1 change: 0 additions & 1 deletion tests/ui/abi/simd-abi-checks-avx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/abi/simd-abi-checks-avx.stderr
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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()();
| ^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/x86_64/evex512-implicit-feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/asm/x86_64/target-feature-attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/asm/x86_64/target-feature-attr.stderr
Original file line number Diff line number Diff line change
@@ -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);
| ^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/simd/target-feature-mixup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}
3 changes: 1 addition & 2 deletions tests/ui/target-feature/gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {}

Expand Down
10 changes: 5 additions & 5 deletions tests/ui/target-feature/gate.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/target-feature/unstable-feature.rs
Original file line number Diff line number Diff line change
@@ -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`
2 changes: 1 addition & 1 deletion tests/ui/target-feature/unstable-feature.stderr
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading