Skip to content

Commit dbbc9ee

Browse files
committed
Gate VPCLMULQDQ support on Rust 1.89+
Removes the “vpclmulqdq” feature flag in favor of Rust 1.89+ since VPCLMULQDQ support is stabilized on 1.89.0. https://releases.rs/docs/1.89.0/
1 parent 2f27164 commit dbbc9ee

File tree

6 files changed

+42
-58
lines changed

6 files changed

+42
-58
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ digest = { version = "0.10", features = ["alloc"] }
2424
rand = "0.9"
2525
libc = "0.2.171"
2626
regex = "1.11.1"
27+
rustversion = "1.0"
2728

2829
[dev-dependencies]
2930
criterion = "0.5"
@@ -44,10 +45,8 @@ harness = false
4445
[features]
4546
alloc = []
4647

47-
# enable experimental VPCLMULQDQ support, which landed in Rust 1.89.0-nightly, will deprecate after 1.89.0 is stable
48-
vpclmulqdq = []
49-
5048
# the features below aren't in use, are deprecated, and will be removed in the next MAJOR version
49+
vpclmulqdq = [] # depreated, VPCLMULQDQ stabilized in Rust 1.89.0
5150
optimize_crc32_auto = [] # deprecated
5251
optimize_crc32_neon_eor3_v9s3x2e_s3 = [] # deprecated
5352
optimize_crc32_neon_v12e_v1 = [] # deprecated

src/arch/mod.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use aarch64::AArch64Ops;
2222
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2323
use x86::X86Ops;
2424

25-
//#[rustversion::since(1.89)]
26-
#[cfg(all(target_arch = "x86_64", feature = "vpclmulqdq"))]
25+
#[rustversion::since(1.89)]
26+
#[cfg(target_arch = "x86_64")]
2727
use vpclmulqdq::Vpclmulqdq512Ops;
2828

2929
mod aarch64;
@@ -49,28 +49,25 @@ pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64
4949
}
5050
}
5151

52-
//#[rustversion::before(1.89)]
52+
#[rustversion::before(1.89)]
5353
#[inline]
54-
#[cfg(all(
55-
not(feature = "vpclmulqdq"),
56-
any(target_arch = "x86", target_arch = "x86_64")
57-
))]
54+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
5855
#[target_feature(enable = "ssse3,sse4.1,pclmulqdq")]
5956
pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
6057
update_x86_sse(state, bytes, params)
6158
}
6259

63-
//#[rustversion::since(1.89)]
60+
#[rustversion::since(1.89)]
6461
#[inline]
65-
#[cfg(all(feature = "vpclmulqdq", target_arch = "x86"))]
62+
#[cfg(target_arch = "x86")]
6663
#[target_feature(enable = "ssse3,sse4.1,pclmulqdq")]
6764
pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
6865
update_x86_sse(state, bytes, params)
6966
}
7067

71-
//#[rustversion::since(1.89)]
68+
#[rustversion::since(1.89)]
7269
#[inline]
73-
#[cfg(all(feature = "vpclmulqdq", target_arch = "x86_64"))]
70+
#[cfg(target_arch = "x86_64")]
7471
#[target_feature(enable = "ssse3,sse4.1,pclmulqdq")]
7572
pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
7673
use std::arch::is_x86_feature_detected;
@@ -117,8 +114,7 @@ unsafe fn update_x86_sse(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
117114
}
118115
}
119116

120-
//#[rustversion::before(1.89)]
121-
#[cfg(not(feature = "vpclmulqdq"))]
117+
#[rustversion::before(1.89)]
122118
pub fn get_target() -> String {
123119
#[cfg(target_arch = "aarch64")]
124120
{
@@ -137,8 +133,7 @@ pub fn get_target() -> String {
137133
return "software-fallback-tables".to_string();
138134
}
139135

140-
//#[rustversion::since(1.89)]
141-
#[cfg(feature = "vpclmulqdq")]
136+
#[rustversion::since(1.89)]
142137
pub fn get_target() -> String {
143138
#[cfg(target_arch = "aarch64")]
144139
{

src/arch/vpclmulqdq.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
//!
55
//! It performs folding using 4 x ZMM registers of 512-bits each.
66
7-
#![cfg(all(target_arch = "x86_64", feature = "vpclmulqdq"))]
7+
#![cfg(target_arch = "x86_64")]
88

9-
//#[rustversion::since(1.89)]
9+
#[rustversion::since(1.89)]
1010
use crate::arch::x86::X86Ops;
1111

12-
//#[rustversion::since(1.89)]
12+
#[rustversion::since(1.89)]
1313
use crate::enums::Reflector;
1414

15-
//#[rustversion::since(1.89)]
15+
#[rustversion::since(1.89)]
1616
use crate::structs::CrcState;
1717

18-
//#[rustversion::since(1.89)]
18+
#[rustversion::since(1.89)]
1919
use crate::traits::{ArchOps, EnhancedCrcWidth};
2020

21-
//#[rustversion::since(1.89)]
21+
#[rustversion::since(1.89)]
2222
use std::arch::x86_64::*;
2323

24-
//#[rustversion::since(1.89)]
24+
#[rustversion::since(1.89)]
2525
use std::ops::BitXor;
2626

2727
/// Implements the ArchOps trait using 512-bit AVX-512 and VPCLMULQDQ instructions at 512 bits.
2828
/// Delegates to X86Ops for standard 128-bit operations
29-
//#[rustversion::since(1.89)]
29+
#[rustversion::since(1.89)]
3030
#[derive(Debug, Copy, Clone)]
3131
pub struct Vpclmulqdq512Ops(X86Ops);
3232

33-
//#[rustversion::since(1.89)]
33+
#[rustversion::since(1.89)]
3434
impl Vpclmulqdq512Ops {
3535
#[inline(always)]
3636
pub fn new() -> Self {
@@ -39,11 +39,11 @@ impl Vpclmulqdq512Ops {
3939
}
4040

4141
// Wrapper for __m512i to make it easier to work with
42-
//#[rustversion::since(1.89)]
42+
#[rustversion::since(1.89)]
4343
#[derive(Debug, Copy, Clone)]
4444
struct Simd512(__m512i);
4545

46-
//#[rustversion::since(1.89)]
46+
#[rustversion::since(1.89)]
4747
impl Simd512 {
4848
#[inline]
4949
#[target_feature(enable = "avx512f")]
@@ -112,7 +112,7 @@ impl Simd512 {
112112
}
113113
}
114114

115-
//#[rustversion::since(1.89)]
115+
#[rustversion::since(1.89)]
116116
impl Vpclmulqdq512Ops {
117117
/// Process aligned blocks using VPCLMULQDQ with 4 x 512-bit registers
118118
///
@@ -339,15 +339,15 @@ impl Vpclmulqdq512Ops {
339339
}
340340

341341
// 512-bit version of the Reflector
342-
//#[rustversion::since(1.89)]
342+
#[rustversion::since(1.89)]
343343
#[derive(Clone, Copy)]
344344
enum Reflector512 {
345345
NoReflector,
346346
ForwardReflector { smask: Simd512 },
347347
}
348348

349349
// Function to create the appropriate reflector based on CRC parameters
350-
//#[rustversion::since(1.89)]
350+
#[rustversion::since(1.89)]
351351
#[inline(always)]
352352
unsafe fn create_reflector512(reflected: bool) -> Reflector512 {
353353
if reflected {
@@ -369,7 +369,7 @@ unsafe fn create_reflector512(reflected: bool) -> Reflector512 {
369369
}
370370

371371
// Function to apply reflection to a 512-bit vector
372-
//#[rustversion::since(1.89)]
372+
#[rustversion::since(1.89)]
373373
#[inline(always)]
374374
unsafe fn reflect_bytes512(reflector: &Reflector512, data: Simd512) -> Simd512 {
375375
match reflector {
@@ -379,12 +379,12 @@ unsafe fn reflect_bytes512(reflector: &Reflector512, data: Simd512) -> Simd512 {
379379
}
380380

381381
// pre-compute the reverse indices for 512-bit shuffling
382-
//#[rustversion::since(1.89)]
382+
#[rustversion::since(1.89)]
383383
static REVERSE_INDICES_512: __m512i =
384384
unsafe { std::mem::transmute([7u64, 6u64, 5u64, 4u64, 3u64, 2u64, 1u64, 0u64]) };
385385

386386
// Implement a 512-bit byte shuffle function
387-
//#[rustversion::since(1.89)]
387+
#[rustversion::since(1.89)]
388388
#[inline]
389389
#[target_feature(enable = "avx512f,avx512bw")]
390390
unsafe fn shuffle_bytes512(data: Simd512, mask: Simd512) -> Simd512 {
@@ -396,7 +396,7 @@ unsafe fn shuffle_bytes512(data: Simd512, mask: Simd512) -> Simd512 {
396396
}
397397

398398
// Delegate all ArchOps methods to the inner X86Ops instance
399-
//#[rustversion::since(1.89)]
399+
#[rustversion::since(1.89)]
400400
impl ArchOps for Vpclmulqdq512Ops {
401401
type Vector = __m128i;
402402

src/arch/x86.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,8 @@ impl ArchOps for X86Ops {
227227
_mm_clmulepi64_si128(a, b, 0x11)
228228
}
229229

230-
//#[rustversion::since(1.89)]
230+
#[rustversion::since(1.89)]
231231
#[inline]
232-
#[cfg(feature = "vpclmulqdq")]
233232
#[target_feature(enable = "avx512f,avx512vl")]
234233
unsafe fn xor3_vectors(
235234
&self,
@@ -244,9 +243,8 @@ impl ArchOps for X86Ops {
244243
self.xor3_vectors_sse(a, b, c)
245244
}
246245

247-
//#[rustversion::before(1.89)]
246+
#[rustversion::before(1.89)]
248247
#[inline]
249-
#[cfg(not(feature = "vpclmulqdq"))]
250248
#[target_feature(enable = "sse4.1")]
251249
unsafe fn xor3_vectors(
252250
&self,
@@ -321,9 +319,8 @@ impl X86Ops {
321319
}
322320
}
323321

324-
//#[rustversion::since(1.89)]
322+
#[rustversion::since(1.89)]
325323
#[inline]
326-
#[cfg(feature = "vpclmulqdq")]
327324
#[target_feature(enable = "avx512f,avx512vl")]
328325
unsafe fn xor3_vectors_avx512(&self, a: __m128i, b: __m128i, c: __m128i) -> __m128i {
329326
_mm_ternarylogic_epi64(

src/crc32/fusion/x86.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@
2020
use std::arch::x86_64::*;
2121

2222
/// Safe wrapper for CRC32 iSCSI calculation using AVX-512
23-
//#[rustversion::before(1.89)]
23+
#[rustversion::before(1.89)]
2424
#[inline(always)]
25-
#[cfg(not(feature = "vpclmulqdq"))]
2625
pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
2726
unsafe { crc32_iscsi_sse_v4s3x3(crc, data.as_ptr(), data.len()) }
2827
}
2928

30-
//#[rustversion::since(1.89)]
29+
#[rustversion::since(1.89)]
3130
#[inline(always)]
32-
#[cfg(feature = "vpclmulqdq")]
3331
pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
3432
if is_x86_feature_detected!("vpclmulqdq")
3533
&& is_x86_feature_detected!("avx512f")
@@ -49,17 +47,15 @@ pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
4947
unsafe { crc32_iscsi_sse_v4s3x3(crc, data.as_ptr(), data.len()) }
5048
}
5149

52-
//#[rustversion::since(1.89)]
50+
#[rustversion::since(1.89)]
5351
#[inline]
54-
#[cfg(feature = "vpclmulqdq")]
5552
#[target_feature(enable = "avx512f,avx512vl,vpclmulqdq")]
5653
unsafe fn clmul_lo_avx512_vpclmulqdq(a: __m512i, b: __m512i) -> __m512i {
5754
_mm512_clmulepi64_epi128(a, b, 0)
5855
}
5956

60-
//#[rustversion::since(1.89)]
57+
#[rustversion::since(1.89)]
6158
#[inline]
62-
#[cfg(feature = "vpclmulqdq")]
6359
#[target_feature(enable = "avx512f,avx512vl,vpclmulqdq")]
6460
unsafe fn clmul_hi_avx512_vpclmulqdq(a: __m512i, b: __m512i) -> __m512i {
6561
_mm512_clmulepi64_epi128(a, b, 17)
@@ -142,9 +138,8 @@ unsafe fn mm_crc32_u64(crc: u32, val: u64) -> u32 {
142138
/// using:
143139
///
144140
/// ./generate -i avx512_vpclmulqdq -p crc32c -a v3x2
145-
//#[rustversion::since(1.89)]
141+
#[rustversion::since(1.89)]
146142
#[inline]
147-
#[cfg(feature = "vpclmulqdq")]
148143
#[target_feature(enable = "avx512f,avx512vl,vpclmulqdq,sse4.2")]
149144
pub unsafe fn crc32_iscsi_avx512_vpclmulqdq_v3x2(
150145
mut crc0: u32,
@@ -341,9 +336,8 @@ pub unsafe fn crc32_iscsi_avx512_vpclmulqdq_v3x2(
341336
/// using:
342337
///
343338
/// ./generate -i avx512 -p crc32c -a v4s3x3
344-
//#[rustversion::since(1.89)]
339+
#[rustversion::since(1.89)]
345340
#[inline]
346-
#[cfg(feature = "vpclmulqdq")]
347341
#[target_feature(enable = "avx2,avx512f,avx512vl,pclmulqdq")]
348342
pub unsafe fn crc32_iscsi_avx512_v4s3x3(mut crc0: u32, mut buf: *const u8, mut len: usize) -> u32 {
349343
// Align to 8-byte boundary using hardware CRC32C instructions
@@ -689,8 +683,7 @@ mod tests {
689683
}
690684
}
691685

692-
//#[rustversion::since(1.89)]
693-
#[cfg(feature = "vpclmulqdq")]
686+
#[rustversion::since(1.89)]
694687
fn test_crc32_iscsi_random(len: usize) {
695688
let mut data = vec![0u8; len];
696689
rng().fill(&mut data[..]);
@@ -728,8 +721,7 @@ mod tests {
728721
}
729722
}
730723

731-
//#[rustversion::before(1.89)]
732-
#[cfg(not(feature = "vpclmulqdq"))]
724+
#[rustversion::before(1.89)]
733725
fn test_crc32_iscsi_random(len: usize) {
734726
let mut data = vec![0u8; len];
735727
rng().fill(&mut data[..]);

0 commit comments

Comments
 (0)