@@ -11,15 +11,12 @@ use target_arch::CpuidResult;
1111use target_arch:: __m128;
1212#[ cfg( any( target_feature = "avx2" , doc) ) ]
1313use target_arch:: __m256i;
14- #[ cfg( all(
15- feature = "nightly" ,
16- any( all( target_feature = "avx512vl" , target_feature = "avx512bf16" ) , doc)
17- ) ) ]
18- use target_arch:: { __m128bh, __m256bh} ;
1914#[ cfg( any( target_feature = "sse2" , doc) ) ]
2015use target_arch:: { __m128d, __m128i} ;
2116#[ cfg( any( target_feature = "avx" , doc) ) ]
2217use target_arch:: { __m256, __m256d} ;
18+ #[ cfg( any( target_feature = "avx512f" , doc) ) ]
19+ use target_arch:: { __m512, __m512d, __m512i} ;
2320
2421pessimize_asm_values ! ( allow( missing_docs) { reg_byte: ( i8 , u8 ) , reg: ( i16 , u16 , i32 , u32 , isize , usize ) } ) ;
2522
@@ -98,18 +95,16 @@ pessimize_asm_values!(
9895) ;
9996
10097/// AVX-512 specific functionality
101- #[ cfg_attr(
102- feature = "nightly" ,
103- doc( cfg( all( feature = "nightly" , target_feature = "avx512f" ) ) )
104- ) ]
105- #[ cfg( all( feature = "nightly" , any( target_feature = "avx512f" , doc) ) ) ]
98+ #[ cfg( any( target_feature = "avx512f" , doc) ) ]
99+ #[ cfg_attr( feature = "nightly" , doc( cfg( target_feature = "avx512f" ) ) ) ]
106100pub mod avx512 {
107101 use super :: * ;
108102 use crate :: Pessimize ;
109103 use core:: arch:: asm;
110104 #[ cfg( any( target_feature = "avx512bf16" , doc) ) ]
111105 use target_arch:: __m512bh;
112- use target_arch:: { __m512, __m512d, __m512i} ;
106+ #[ cfg( any( all( target_feature = "avx512vl" , target_feature = "avx512bf16" ) , doc) ) ]
107+ use target_arch:: { __m128bh, __m256bh} ;
113108
114109 // Basic register type support
115110 pessimize_asm_values ! (
@@ -152,7 +147,7 @@ pub mod avx512 {
152147 $(
153148 // This is one of the primitive Pessimize impls on which
154149 // the PessimizeCast/BorrowPessimize stack is built
155- #[ $doc_cfg]
150+ #[ cfg_attr ( feature = "nightly" , $doc_cfg) ]
156151 unsafe impl Pessimize for Mask <$mask_impl> {
157152 #[ inline]
158153 fn hide( mut self ) -> Self {
@@ -206,6 +201,8 @@ mod safe_arch_types {
206201 use safe_arch:: { m128d, m128i} ;
207202 #[ cfg( any( target_feature = "avx" , doc) ) ]
208203 use safe_arch:: { m256, m256d} ;
204+ #[ cfg( any( target_feature = "avx512f" , doc) ) ]
205+ use safe_arch:: { m512, m512d, m512i} ;
209206
210207 #[ cfg( any( target_feature = "sse" , doc) ) ]
211208 pessimize_newtypes ! (
@@ -236,6 +233,16 @@ mod safe_arch_types {
236233 doc( cfg( all( feature = "safe_arch" , target_feature = "avx2" ) ) )
237234 { m256i{ __m256i } }
238235 ) ;
236+
237+ #[ cfg( any( target_feature = "avx512f" , doc) ) ]
238+ pessimize_newtypes ! (
239+ doc( cfg( all( feature = "safe_arch" , target_feature = "avx512f" ) ) )
240+ {
241+ m512{ __m512 } ,
242+ m512d{ __m512d } ,
243+ m512i{ __m512i }
244+ }
245+ ) ;
239246}
240247
241248// Support portable_simd if enabled
@@ -731,12 +738,18 @@ mod tests {
731738 }
732739 }
733740
734- #[ cfg( all( feature = "nightly" , target_feature = "avx512f" ) ) ]
735- mod avx512 {
736- use super :: * ;
737-
738- #[ test]
739- fn avx512f ( ) {
741+ #[ cfg( target_feature = "avx512f" ) ]
742+ #[ test]
743+ fn avx512f ( ) {
744+ use safe_arch:: { m512, m512d, m512i} ;
745+ test_simd :: < i32 , 16 , m512i > ( i32:: MIN , i32:: MAX ) ;
746+ test_simd :: < u32 , 16 , m512i > ( u32:: MIN , u32:: MAX ) ;
747+ test_simd :: < f32 , 16 , m512 > ( f32:: MIN , f32:: MAX ) ;
748+ test_simd :: < i64 , 8 , m512i > ( i64:: MIN , i64:: MAX ) ;
749+ test_simd :: < u64 , 8 , m512i > ( u64:: MIN , u64:: MAX ) ;
750+ test_simd :: < f64 , 8 , m512d > ( f64:: MIN , f64:: MAX ) ;
751+ #[ cfg( feature = "nightly" ) ]
752+ {
740753 portable_simd_tests ! (
741754 ( i32 , 16 ) ,
742755 ( u32 , 16 ) ,
@@ -746,21 +759,21 @@ mod tests {
746759 ( f64 , 8 )
747760 ) ;
748761 portable_mask_tests ! ( ( i32 , 16 ) , ( i64 , 8 ) ) ;
749- #[ cfg( target_arch = "x86" ) ]
750- {
751- portable_simd_tests ! ( ( isize , 16 ) , ( usize , 16 ) ) ;
752- portable_mask_tests ! ( ( isize , 16 ) ) ;
753- }
754- #[ cfg( target_arch = "x86_64" ) ]
755- {
756- portable_simd_tests ! ( ( isize , 8 ) , ( usize , 8 ) ) ;
757- portable_mask_tests ! ( ( isize , 8 ) ) ;
758- }
762+ portable_simd_tests ! ( ( isize , 8 ) , ( usize , 8 ) ) ;
763+ portable_mask_tests ! ( ( isize , 8 ) ) ;
759764 }
765+ }
760766
761- #[ test]
762- #[ ignore]
763- fn avx512f_optim ( ) {
767+ #[ cfg( target_feature = "avx512f" ) ]
768+ #[ test]
769+ #[ ignore]
770+ fn avx512f_optim ( ) {
771+ use safe_arch:: { m512, m512d, m512i} ;
772+ test_unoptimized_value_type :: < m512 > ( ) ;
773+ test_unoptimized_value_type :: < m512d > ( ) ;
774+ test_unoptimized_value_type :: < m512i > ( ) ;
775+ #[ cfg( feature = "nightly" ) ]
776+ {
764777 portable_simd_tests_optim ! (
765778 ( i32 , 16 ) ,
766779 ( u32 , 16 ) ,
@@ -770,26 +783,33 @@ mod tests {
770783 ( f64 , 8 )
771784 ) ;
772785 portable_mask_tests_optim ! ( ( i32 , 16 ) , ( i64 , 8 ) ) ;
773- #[ cfg( target_arch = "x86" ) ]
774- {
775- portable_simd_tests_optim ! ( ( isize , 16 ) , ( usize , 16 ) ) ;
776- portable_mask_tests_optim ! ( ( isize , 16 ) ) ;
777- }
778- #[ cfg( target_arch = "x86_64" ) ]
779- {
780- portable_simd_tests_optim ! ( ( isize , 8 ) , ( usize , 8 ) ) ;
781- portable_mask_tests_optim ! ( ( isize , 8 ) ) ;
782- }
786+ portable_simd_tests_optim ! ( ( isize , 8 ) , ( usize , 8 ) ) ;
787+ portable_mask_tests_optim ! ( ( isize , 8 ) ) ;
783788 }
789+ }
784790
785- #[ cfg( target_feature = "avx512bw" ) ]
786- #[ test]
787- fn avx512bw ( ) {
791+ #[ cfg( target_feature = "avx512bw" ) ]
792+ #[ test]
793+ fn avx512bw ( ) {
794+ use safe_arch:: m512i;
795+ test_simd :: < i8 , 64 , m512i > ( i8:: MIN , i8:: MAX ) ;
796+ test_simd :: < u8 , 64 , m512i > ( u8:: MIN , u8:: MAX ) ;
797+ test_simd :: < i16 , 32 , m512i > ( i16:: MIN , i16:: MAX ) ;
798+ test_simd :: < u16 , 32 , m512i > ( u16:: MIN , u16:: MAX ) ;
799+ #[ cfg( feature = "nightly" ) ]
800+ {
788801 portable_simd_tests ! ( ( i8 , 64 ) , ( u8 , 64 ) , ( i16 , 32 ) , ( u16 , 32 ) ) ;
789802 portable_mask_tests ! ( ( i8 , 64 ) , ( i16 , 32 ) ) ;
790803 }
804+ }
805+
806+ // This is nightly-only even though the rest of avx512 is not nightly only
807+ // anymore because we can't easily test without safe_arch or portable_simd
808+ // and portable_simd doesn't have support for AVX-512 yet.
809+ #[ cfg( all( feature = "nightly" , target_feature = "avx512bw" ) ) ]
810+ mod avx512 {
811+ use super :: * ;
791812
792- #[ cfg( target_feature = "avx512bw" ) ]
793813 #[ test]
794814 #[ ignore]
795815 fn avx512bw_optim ( ) {
0 commit comments