From f2e262f9e470d6eac26662c5423d0a0e0443e333 Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Thu, 27 Feb 2020 12:17:26 -0500 Subject: [PATCH 1/3] re-stabilize the AVX-512 features that were stabilized in Rust 1.27.0 https://github.com/rust-lang/stdarch/pull/739 added per-feature stabilization of runtime CPU feature detection. In so doing, it de-stabilized some detection features that had been stable since Rust 1.27.0, breaking some published crates (on nightly). This commit re-stabilizes the subset of AVX-512 detection features that were included in 1.27.0 (that is, the pre-Ice-Lake subset). Other instruction sets (MMX in particular) remain de-stabilized, pending a decision about whether should ever stabilize them. See https://github.com/rust-lang/rust/issues/68905. --- crates/std_detect/src/detect/arch/x86.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/std_detect/src/detect/arch/x86.rs b/crates/std_detect/src/detect/arch/x86.rs index 9a61e5e768..1122896fb3 100644 --- a/crates/std_detect/src/detect/arch/x86.rs +++ b/crates/std_detect/src/detect/arch/x86.rs @@ -114,25 +114,25 @@ features! { /// AVX (Advanced Vector Extensions) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx2: "avx2"; /// AVX2 (Advanced Vector Extensions 2) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512f: "avx512f" ; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512f: "avx512f" ; /// AVX-512 F (Foundation) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512cd: "avx512cd" ; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512cd: "avx512cd" ; /// AVX-512 CD (Conflict Detection Instructions) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512er: "avx512er"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512er: "avx512er"; /// AVX-512 ER (Expo nential and Reciprocal Instructions) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512pf: "avx512pf"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512pf: "avx512pf"; /// AVX-512 PF (Prefetch Instructions) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512bw: "avx512bw"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512bw: "avx512bw"; /// AVX-512 BW (Byte and Word Instructions) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512dq: "avx512dq"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512dq: "avx512dq"; /// AVX-512 DQ (Doubleword and Quadword) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vl: "avx512vl"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vl: "avx512vl"; /// AVX-512 VL (Vector Length Extensions) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512ifma: "avx512ifma"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512ifma: "avx512ifma"; /// AVX-512 IFMA (Integer Fused Multiply Add) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vbmi: "avx512vbmi"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vbmi: "avx512vbmi"; /// AVX-512 VBMI (Vector Byte Manipulation Instructions) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vpopcntdq: "avx512vpopcntdq"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vpopcntdq: "avx512vpopcntdq"; /// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and /// Quadword) @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vbmi2: "avx512vbmi2"; From d9b91b40d687dec0c7178a3088bf8fd2898779ee Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Thu, 27 Feb 2020 17:14:55 -0500 Subject: [PATCH 2/3] add a comment explaining feature detection stability --- crates/std_detect/src/detect/arch/x86.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/std_detect/src/detect/arch/x86.rs b/crates/std_detect/src/detect/arch/x86.rs index 1122896fb3..827225cc51 100644 --- a/crates/std_detect/src/detect/arch/x86.rs +++ b/crates/std_detect/src/detect/arch/x86.rs @@ -114,6 +114,10 @@ features! { /// AVX (Advanced Vector Extensions) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx2: "avx2"; /// AVX2 (Advanced Vector Extensions 2) + // Detection for the AVX-512 features below was accidentally stabilized in + // Rust 1.27.0, even though the corresponding intrinsics are still unstable + // or unimplemeted. There are stable callers who rely on detection support, + // e.g. to call AVX-512 C code via FFI. @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512f: "avx512f" ; /// AVX-512 F (Foundation) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512cd: "avx512cd" ; From 134e248ab0793d619a7ff532bcbcc581627f32ea Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Wed, 11 Mar 2020 17:17:17 -0400 Subject: [PATCH 3/3] adjust stabilizations to match most recent proposal https://github.com/rust-lang/rust/issues/68905#issuecomment-595376319 --- crates/std_detect/src/detect/arch/x86.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/std_detect/src/detect/arch/x86.rs b/crates/std_detect/src/detect/arch/x86.rs index 827225cc51..578910054e 100644 --- a/crates/std_detect/src/detect/arch/x86.rs +++ b/crates/std_detect/src/detect/arch/x86.rs @@ -92,7 +92,7 @@ features! { /// RDSEED @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tsc: "tsc"; /// TSC (Time Stamp Counter) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] mmx: "mmx"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] mmx: "mmx"; /// MMX (MultiMedia eXtensions) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse: "sse"; /// SSE (Streaming SIMD Extensions) @@ -106,7 +106,7 @@ features! { /// SSE4.1 (Streaming SIMD Extensions 4.1) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_2: "sse4.2"; /// SSE4.2 (Streaming SIMD Extensions 4.2) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sse4a: "sse4a"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4a: "sse4a"; /// SSE4a (Streaming SIMD Extensions 4a) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sha: "sha"; /// SHA @@ -132,11 +132,11 @@ features! { /// AVX-512 DQ (Doubleword and Quadword) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vl: "avx512vl"; /// AVX-512 VL (Vector Length Extensions) - @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512ifma: "avx512ifma"; + @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512ifma: "avx512ifma"; /// AVX-512 IFMA (Integer Fused Multiply Add) - @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vbmi: "avx512vbmi"; + @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vbmi: "avx512vbmi"; /// AVX-512 VBMI (Vector Byte Manipulation Instructions) - @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vpopcntdq: "avx512vpopcntdq"; + @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vpopcntdq: "avx512vpopcntdq"; /// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and /// Quadword) @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vbmi2: "avx512vbmi2"; @@ -165,7 +165,7 @@ features! { /// BMI2 (Bit Manipulation Instructions 2) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] lzcnt: "lzcnt"; /// ABM (Advanced Bit Manipulation) / LZCNT (Leading Zero Count) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] tbm: "tbm"; + @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tbm: "tbm"; /// TBM (Trailing Bit Manipulation) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] popcnt: "popcnt"; /// POPCNT (Population Count)