@@ -29,23 +29,32 @@ pub fn is_enabled_sse42() -> bool {
2929#[ inline( always) ]
3030pub fn is_enabled_avx2_and_bmi2 ( ) -> bool {
3131 #[ cfg( any( target_arch = "x86_64" , target_arch = "x86" ) ) ]
32- #[ cfg( feature = "std" ) ]
3332 {
34- use std:: sync:: atomic:: { AtomicU32 , Ordering } ;
35-
36- static CACHE : AtomicU32 = AtomicU32 :: new ( 2 ) ;
37-
38- return match CACHE . load ( Ordering :: Relaxed ) {
39- 0 => false ,
40- 1 => true ,
41- _ => {
42- let detected = std:: is_x86_feature_detected!( "avx2" )
43- && std:: is_x86_feature_detected!( "bmi1" )
44- && std:: is_x86_feature_detected!( "bmi2" ) ;
45- CACHE . store ( u32:: from ( detected) , Ordering :: Relaxed ) ;
46- detected
47- }
48- } ;
33+ #[ cfg( all(
34+ target_feature = "avx2" ,
35+ target_feature = "bmi1" ,
36+ target_feature = "bmi2"
37+ ) ) ]
38+ return true ;
39+
40+ #[ cfg( feature = "std" ) ]
41+ {
42+ use std:: sync:: atomic:: { AtomicU32 , Ordering } ;
43+
44+ static CACHE : AtomicU32 = AtomicU32 :: new ( 2 ) ;
45+
46+ return match CACHE . load ( Ordering :: Relaxed ) {
47+ 0 => false ,
48+ 1 => true ,
49+ _ => {
50+ let detected = std:: is_x86_feature_detected!( "avx2" )
51+ && std:: is_x86_feature_detected!( "bmi1" )
52+ && std:: is_x86_feature_detected!( "bmi2" ) ;
53+ CACHE . store ( u32:: from ( detected) , Ordering :: Relaxed ) ;
54+ detected
55+ }
56+ } ;
57+ }
4958 }
5059
5160 false
0 commit comments