@@ -15,12 +15,48 @@ fn main() {
1515 assert ! ( is_x86_feature_detected!( "avx512vpopcntdq" ) ) ;
1616
1717 unsafe {
18+ test_avx512 ( ) ;
1819 test_avx512bitalg ( ) ;
1920 test_avx512vpopcntdq ( ) ;
2021 test_avx512ternarylogic ( ) ;
2122 }
2223}
2324
25+ #[ target_feature( enable = "avx512bw" ) ]
26+ unsafe fn test_avx512 ( ) {
27+ #[ target_feature( enable = "avx512bw" ) ]
28+ unsafe fn test_mm512_sad_epu8 ( ) {
29+ let a = _mm512_set_epi8 (
30+ 71 , 70 , 69 , 68 , 67 , 66 , 65 , 64 , //
31+ 55 , 54 , 53 , 52 , 51 , 50 , 49 , 48 , //
32+ 47 , 46 , 45 , 44 , 43 , 42 , 41 , 40 , //
33+ 39 , 38 , 37 , 36 , 35 , 34 , 33 , 32 , //
34+ 31 , 30 , 29 , 28 , 27 , 26 , 25 , 24 , //
35+ 23 , 22 , 21 , 20 , 19 , 18 , 17 , 16 , //
36+ 15 , 14 , 13 , 12 , 11 , 10 , 9 , 8 , //
37+ 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 , //
38+ ) ;
39+
40+ // `d` is the absolute difference with the corresponding row in `a`.
41+ let b = _mm512_set_epi8 (
42+ 63 , 62 , 61 , 60 , 59 , 58 , 57 , 56 , // lane 7 (d = 8)
43+ 62 , 61 , 60 , 59 , 58 , 57 , 56 , 55 , // lane 6 (d = 7)
44+ 53 , 52 , 51 , 50 , 49 , 48 , 47 , 46 , // lane 5 (d = 6)
45+ 44 , 43 , 42 , 41 , 40 , 39 , 38 , 37 , // lane 4 (d = 5)
46+ 35 , 34 , 33 , 32 , 31 , 30 , 29 , 28 , // lane 3 (d = 4)
47+ 26 , 25 , 24 , 23 , 22 , 21 , 20 , 19 , // lane 2 (d = 3)
48+ 17 , 16 , 15 , 14 , 13 , 12 , 11 , 10 , // lane 1 (d = 2)
49+ 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , // lane 0 (d = 1)
50+ ) ;
51+
52+ let r = _mm512_sad_epu8 ( a, b) ;
53+ let e = _mm512_set_epi64 ( 64 , 56 , 48 , 40 , 32 , 24 , 16 , 8 ) ;
54+
55+ assert_eq_m512i ( r, e) ;
56+ }
57+ test_mm512_sad_epu8 ( ) ;
58+ }
59+
2460// Some of the constants in the tests below are just bit patterns. They should not
2561// be interpreted as integers; signedness does not make sense for them, but
2662// __mXXXi happens to be defined in terms of signed integers.
0 commit comments