1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavxvnniint8" } */
3 /* { dg-require-effective-target avxvnniint8 } */
4 #define AVXVNNIINT8
5 #ifndef CHECK
6 #define CHECK "avx-check.h"
7 #endif
8
9 #ifndef TEST
10 #define TEST avx_test
11 #endif
12
13 #include CHECK
14
15 static void
16 CALC (int *r, int *dst, char *s1, unsigned char *s2, int size)
17 {
18 short tempres[32];
19 for (int i = 0; i < size; i++) {
20 tempres[i] = (short) s1[i] * (unsigned short) s2[i];
21 }
22 for (int i = 0; i < size / 4; i++) {
23 long long test = (long long) dst[i] + tempres[i * 4] + tempres[i * 4 + 1]
24 + tempres[i * 4 + 2] + tempres[i * 4 + 3];
25 r[i] = test > 0x7FFFFFFF ? 0x7FFFFFFF : test;
26 }
27 }
28
29 void
30 TEST (void)
31 {
32 int i;
33 union256i_d res_256;
34 union256i_b src1_256;
35 union256i_ub src2_256;
36 int res_ref_256[8];
37
38 for (i = 0; i < 32; i++)
39 {
40 int sign = i % 2 ? 1 : -1;
41 src1_256.a[i] = 10 + 3 * i + sign;
42 src2_256.a[i] = sign * 10 * i * i;
43 }
44
45 for (i = 0; i < 8; i++)
46 res_256.a[i] = 0x7fffffff;
47
48 CALC (res_ref_256, res_256.a, src1_256.a, src2_256.a, 32);
49 res_256.x = _mm256_dpbsuds_epi32 (res_256.x, src1_256.x, src2_256.x);
50 if (check_union256i_d (res_256, res_ref_256))
51 abort ();
52
53 union128i_d res_128;
54 union128i_b src1_128;
55 union128i_ub src2_128;
56 int res_ref_128[4];
57
58 for (i = 0; i < 16; i++)
59 {
60 int sign = i % 2 ? 1 : -1;
61 src1_128.a[i] = 10 + 3 * i * i + sign;
62 src2_128.a[i] = sign * 10 * i * i;
63 }
64
65 for (i = 0; i < 4; i++)
66 res_128.a[i] = 0x7fffffff;
67
68 CALC (res_ref_128, res_128.a, src1_128.a, src2_128.a, 16);
69 res_128.x = _mm_dpbsuds_epi32 (res_128.x, src1_128.x, src2_128.x);
70 if (check_union128i_d (res_128, res_ref_128))
71 abort ();
72 }