Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx10_2-512-vmpsadbw-2.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -march=x86-64-v3 -mavx10.2" } */
3 /* { dg-require-effective-target avx10_2 } */
4
5 #ifndef AVX10_2
6 #define AVX10_2
7 #define AVX10_2_512
8 #define AVX10_512BIT
9 #endif
10 #include "avx10-helper.h"
11
12 #define SRC_SIZE (AVX512F_LEN / 8)
13 #define SIZE (AVX512F_LEN / 16)
14 #include "avx512f-mask-type.h"
15
16 static void
17 CALC (short* dst, char* src1, char* src2, int cont)
18 {
19 int blk2_pos, blk1_pos, i, j, k, c;
20 char blk1[12], blk2[4], x;
21 short tmp[4], s;
22
23 for (k = 0; k < AVX512F_LEN / 128; k++)
24 {
25 c = cont & 0xff;
26 if (k % 2 == 1)
27 c >>= 3;
28 blk2_pos = (c & 3) * 4;
29 blk1_pos = ((c >> 2) & 1) * 4;
30
31 for (i = 0; i < 11; i++)
32 blk1[i] = src1[16 * k + i + blk1_pos];
33
34 for (i = 0; i < 4; i++)
35 blk2[i] = src2[16 * k + i + blk2_pos];
36
37 for (i = 0; i < 8; i++)
38 {
39 for (j = 0; j < 4; j++)
40 {
41 x = blk1[j + i] - blk2[j];
42 tmp[j] = x > 0 ? x : -x;
43 }
44
45 s = 0;
46 for (j = 0; j < 4; j++)
47 s += tmp[j];
48 dst[8 * k + i] = s;
49 }
50 }
51 }
52
53 void
54 TEST (void)
55 {
56 int i;
57 UNION_TYPE (AVX512F_LEN, i_w) res1, res2, res3;
58 UNION_TYPE (AVX512F_LEN, i_b) src1;
59 UNION_TYPE (AVX512F_LEN, i_b) src2;
60 MASK_TYPE mask = MASK_VALUE;
61 short res_ref[SIZE], res_ref2[SIZE];
62
63 for (i = 0; i < SRC_SIZE; i++)
64 {
65 src1.a[i] = 10 + 2 * i;
66 src2.a[i] = 3 * i;
67 }
68
69 for (i = 0; i < SIZE; i++)
70 {
71 res1.a[i] = 0x7FFF;
72 res2.a[i] = DEFAULT_VALUE;
73 res3.a[i] = DEFAULT_VALUE;
74 }
75
76 CALC (res_ref, src1.a, src2.a, 0x21);
77 CALC (res_ref2, src1.a, src2.a, 0x21);
78
79 res1.x = INTRINSIC (_mpsadbw_epu8) (src1.x, src2.x, 0x21);
80 res2.x = INTRINSIC (_mask_mpsadbw_epu8) (res2.x, mask, src1.x, src2.x, 0x21);
81 res3.x = INTRINSIC (_maskz_mpsadbw_epu8) (mask, src1.x, src2.x, 0x21);
82
83 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
84 abort ();
85
86 MASK_MERGE (i_w) (res_ref2, mask, SIZE);
87 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref2))
88 abort ();
89
90 MASK_ZERO (i_w) (res_ref2, mask, SIZE);
91 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref2))
92 abort ();
93 }