@@ -10,8 +10,8 @@ pub fn slide_hash(state: &mut crate::deflate::State) {
1010
1111fn slide_hash_chain ( table : & mut [ u16 ] , wsize : u16 ) {
1212 #[ cfg( target_arch = "x86_64" ) ]
13- if crate :: cpu_features:: is_enabled_avx2 ( ) {
14- // SAFETY: the avx2 target feature is enabled.
13+ if crate :: cpu_features:: is_enabled_avx2_and_bmi2 ( ) {
14+ // SAFETY: the avx2 and bmi2 target feature are enabled.
1515 return unsafe { avx2:: slide_hash_chain ( table, wsize) } ;
1616 }
1717
@@ -54,6 +54,7 @@ mod avx2 {
5454 ///
5555 /// Behavior is undefined if the `avx2` target feature is not enabled
5656 #[ target_feature( enable = "avx2" ) ]
57+ #[ target_feature( enable = "bmi2" ) ]
5758 pub unsafe fn slide_hash_chain ( table : & mut [ u16 ] , wsize : u16 ) {
5859 // 64 means that 4 256-bit values can be processed per iteration.
5960 // That appear to be the optimal amount for avx2.
@@ -155,7 +156,7 @@ mod tests {
155156 #[ test]
156157 #[ cfg( target_arch = "x86_64" ) ]
157158 fn test_slide_hash_avx2 ( ) {
158- if crate :: cpu_features:: is_enabled_avx2 ( ) {
159+ if crate :: cpu_features:: is_enabled_avx2_and_bmi2 ( ) {
159160 let mut input = INPUT ;
160161
161162 unsafe { avx2:: slide_hash_chain ( & mut input, WSIZE ) } ;
0 commit comments