Debian Codegraph @

gcc/testsuite/gcc.target/i386/vnniint16-auto-vectorize-2.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavxvnniint16" } */
3 /* { dg-require-effective-target avxvnniint16 } */
4
5 #ifndef AVX10_2
6 #define AVXVNNIINT16
7 #endif
8
9 #ifndef CHECK
10 #define CHECK "avx-check.h"
11 #endif
12
13 #include CHECK
14 #include "vnniint16-auto-vectorize-1.c"
15
16 #ifndef TEST
17 #define TEST avx_test
18 #endif
19
20 #ifndef N
21 #define N 256
22 #endif
23
24 short a_i16[N];
25 unsigned short b_u16[N], c_u16[N], d_u16[N];
26 int i16_exp, i16_ref;
27
28 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
29 udot_prod_hi_scalar (unsigned short * restrict a, unsigned short * restrict b,
30 int c, int n)
31 {
32 int i;
33 for (i = 0; i < n; i++)
34 {
35 c += ((int) a[i] * (int) b[i]);
36 }
37 return c;
38 }
39
40 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
41 usdot_prod_hi_scalar (unsigned short * restrict a, short *restrict b,
42 int c, int n)
43 {
44 int i;
45 for (i = 0; i < n; i++)
46 {
47 c += ((int) a[i] * (int) b[i]);
48 }
49 return c;
50 }
51
52 void init ()
53 {
54 int i;
55
56 i16_exp = i16_ref = 65535;
57
58 for (i = 0; i < N; i++)
59 {
60 a_i16[i] = -i + 2;
61 b_u16[i] = i * 2;
62 c_u16[i] = i * 3;
63 d_u16[i] = i * 4;
64 }
65 }
66
67 void
68 TEST (void)
69 {
70 init ();
71 i16_exp = usdot_prod_hi (a_i16, b_u16, i16_exp, N);
72 i16_ref = usdot_prod_hi_scalar (a_i16, b_u16, i16_ref, N);
73 if (i16_exp != i16_ref)
74 abort ();
75
76 init ();
77 i16_exp = udot_prod_hi (c_u16, d_u16, i16_exp, N);
78 i16_ref = udot_prod_hi_scalar (c_u16, d_u16, i16_ref, N);
79 if (i16_exp != i16_ref)
80 abort ();
81 }