@@ -105,25 +105,16 @@ pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: &CrcParams) -> u64
105105
106106 match get_arch_ops ( ) {
107107 #[ cfg( target_arch = "x86_64" ) ]
108- ArchOpsInstance :: X86_64Avx512Vpclmulqdq ( ops) => match params. width {
109- 64 => algorithm:: update :: < _ , Width64 > ( state, bytes, params, ops) ,
110- 32 => algorithm:: update :: < _ , Width32 > ( state as u32 , bytes, params, ops) as u64 ,
111- 16 => algorithm:: update :: < _ , Width16 > ( state as u16 , bytes, params, ops) as u64 ,
112- _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
113- } ,
108+ ArchOpsInstance :: X86_64Avx512Vpclmulqdq ( ops) => {
109+ update_x86_64_avx512_vpclmulqdq ( state, bytes, params, * ops)
110+ }
114111 #[ cfg( target_arch = "x86_64" ) ]
115- ArchOpsInstance :: X86_64Avx512Pclmulqdq ( ops) => match params. width {
116- 64 => algorithm:: update :: < _ , Width64 > ( state, bytes, params, ops) ,
117- 32 => algorithm:: update :: < _ , Width32 > ( state as u32 , bytes, params, ops) as u64 ,
118- 16 => algorithm:: update :: < _ , Width16 > ( state as u16 , bytes, params, ops) as u64 ,
119- _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
120- } ,
121- ArchOpsInstance :: X86SsePclmulqdq ( ops) => match params. width {
122- 64 => algorithm:: update :: < _ , Width64 > ( state, bytes, params, ops) ,
123- 32 => algorithm:: update :: < _ , Width32 > ( state as u32 , bytes, params, ops) as u64 ,
124- 16 => algorithm:: update :: < _ , Width16 > ( state as u16 , bytes, params, ops) as u64 ,
125- _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
126- } ,
112+ ArchOpsInstance :: X86_64Avx512Pclmulqdq ( ops) => {
113+ update_x86_64_avx512_pclmulqdq ( state, bytes, params, * ops)
114+ }
115+ ArchOpsInstance :: X86SsePclmulqdq ( ops) => {
116+ update_x86_sse_pclmulqdq ( state, bytes, params, * ops)
117+ }
127118 ArchOpsInstance :: SoftwareFallback => crate :: arch:: software:: update ( state, bytes, params) ,
128119 }
129120}
@@ -139,16 +130,66 @@ pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: &CrcParams) -> u64
139130 use crate :: feature_detection:: { get_arch_ops, ArchOpsInstance } ;
140131
141132 match get_arch_ops ( ) {
142- ArchOpsInstance :: X86SsePclmulqdq ( ops) => match params. width {
143- 64 => algorithm:: update :: < _ , Width64 > ( state, bytes, params, ops) ,
144- 32 => algorithm:: update :: < _ , Width32 > ( state as u32 , bytes, params, ops) as u64 ,
145- 16 => algorithm:: update :: < _ , Width16 > ( state as u16 , bytes, params, ops) as u64 ,
146- _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
147- } ,
133+ ArchOpsInstance :: X86SsePclmulqdq ( ops) => {
134+ update_x86_sse_pclmulqdq ( state, bytes, params, * ops)
135+ }
148136 ArchOpsInstance :: SoftwareFallback => crate :: arch:: software:: update ( state, bytes, params) ,
149137 }
150138}
151139
140+ #[ inline]
141+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
142+ #[ target_feature( enable = "sse4.1,pclmulqdq" ) ]
143+ unsafe fn update_x86_sse_pclmulqdq (
144+ state : u64 ,
145+ bytes : & [ u8 ] ,
146+ params : & CrcParams ,
147+ ops : crate :: arch:: x86:: sse:: X86SsePclmulqdqOps ,
148+ ) -> u64 {
149+ match params. width {
150+ 64 => algorithm:: update :: < _ , Width64 > ( state, bytes, params, & ops) ,
151+ 32 => algorithm:: update :: < _ , Width32 > ( state as u32 , bytes, params, & ops) as u64 ,
152+ 16 => algorithm:: update :: < _ , Width16 > ( state as u16 , bytes, params, & ops) as u64 ,
153+ _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
154+ }
155+ }
156+
157+ #[ rustversion:: since( 1.89 ) ]
158+ #[ inline]
159+ #[ cfg( target_arch = "x86_64" ) ]
160+ #[ target_feature( enable = "avx512vl,pclmulqdq" ) ]
161+ unsafe fn update_x86_64_avx512_pclmulqdq (
162+ state : u64 ,
163+ bytes : & [ u8 ] ,
164+ params : & CrcParams ,
165+ ops : crate :: arch:: x86_64:: avx512:: X86_64Avx512PclmulqdqOps ,
166+ ) -> u64 {
167+ match params. width {
168+ 64 => algorithm:: update :: < _ , Width64 > ( state, bytes, params, & ops) ,
169+ 32 => algorithm:: update :: < _ , Width32 > ( state as u32 , bytes, params, & ops) as u64 ,
170+ 16 => algorithm:: update :: < _ , Width16 > ( state as u16 , bytes, params, & ops) as u64 ,
171+ _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
172+ }
173+ }
174+
175+ #[ rustversion:: since( 1.89 ) ]
176+ #[ inline]
177+ #[ cfg( target_arch = "x86_64" ) ]
178+ #[ target_feature( enable = "avx512vl,vpclmulqdq" ) ]
179+ unsafe fn update_x86_64_avx512_vpclmulqdq (
180+ state : u64 ,
181+ bytes : & [ u8 ] ,
182+ params : & CrcParams ,
183+ ops : crate :: arch:: x86_64:: avx512_vpclmulqdq:: X86_64Avx512VpclmulqdqOps ,
184+ ) -> u64 {
185+ match params. width {
186+ 64 => algorithm:: update :: < _ , Width64 > ( state, bytes, params, & ops) ,
187+ 32 => algorithm:: update :: < _ , Width32 > ( state as u32 , bytes, params, & ops) as u64 ,
188+ 16 => algorithm:: update :: < _ , Width16 > ( state as u16 , bytes, params, & ops) as u64 ,
189+ _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
190+ }
191+ }
192+
152193#[ inline]
153194#[ cfg( all(
154195 not( target_arch = "x86" ) ,
0 commit comments