Debian Codegraph @

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

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavxvnniint8" } */
3 /* { dg-require-effective-target avxvnniint8 } */
4
5 #ifndef AVX10_2
6 #define AVXVNNIINT8
7 #endif
8
9 #ifndef CHECK
10 #define CHECK "avx-check.h"
11 #endif
12
13 #include CHECK
14 #include "vnniint8-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 char a_i8[N], b_i8[N];
25 unsigned char c_u8[N], d_u8[N];
26 int i8_exp, i8_ref;
27
28 int __attribute__((noipa, optimize("no-tree-vectorize")))
29 sdot_prod_qi_scalar (char * restrict a, char * 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__((noipa, optimize("no-tree-vectorize")))
41 udot_prod_qi_scalar (unsigned char * restrict a, unsigned char *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 i8_exp = i8_ref = 127;
57
58 for (i = 0; i < N; i++)
59 {
60 a_i8[i] = (-i + 4) % 128;
61 b_i8[i] = (i + 1) % 128;
62 c_u8[i] = (i + 3) % 256;
63 d_u8[i] = (i + 5) % 256;
64 }
65 }
66
67 void
68 TEST (void)
69 {
70 init ();
71 i8_exp = sdot_prod_qi (a_i8, b_i8, i8_exp, N);
72 i8_ref = sdot_prod_qi_scalar (a_i8, b_i8, i8_ref, N);
73 if (i8_exp != i8_ref)
74 abort ();
75
76 init ();
77 i8_exp = udot_prod_qi (c_u8, d_u8, i8_exp, N);
78 i8_ref = udot_prod_qi_scalar (c_u8, d_u8, i8_ref, N);
79 if (i8_exp != i8_ref)
80 abort ();
81 }