Debian Codegraph @

gcc/testsuite/gcc.target/i386/pr113079-2.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavxvnniint8 -mavxvnni -mavxvnniint16" } */
3 /* { dg-require-effective-target avxvnniint16 } */
4 /* { dg-require-effective-target avxvnniint8 } */
5
6 #define AVXVNNIINT16
7 #define AVXVNNIINT8
8 #ifndef CHECK
9 #define CHECK "avx-check.h"
10 #endif
11
12 #ifndef TEST
13 #define TEST avx_test
14 #endif
15
16 #include CHECK
17 #include "pr113079.c"
18
19 #define N 256
20
21 short hs1[4], hs2[4];
22 unsigned short hu1[4], hu2[4];
23 char qs1[16], qs2[16];
24 unsigned char qu1[16], qu2[16];
25
26 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
27 usdot_prodv4hi_scalar (unsigned short *a, short *b, int c)
28 {
29 int i;
30 for (i = 0; i < 4; i++)
31 {
32 c += ((int) a[i] * (int) b[i]);
33 }
34 return c;
35 }
36
37 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
38 udot_prodv4hi_scalar (unsigned short *a, unsigned short *b, int c)
39 {
40 int i;
41 for (i = 0; i < 4; i++)
42 {
43 c += ((int) a[i] * (int) b[i]);
44 }
45 return c;
46 }
47
48 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
49 sdot_prodv4hi_scalar (short *a, short *b, int c)
50 {
51 int i;
52 for (i = 0; i < 4; i++)
53 {
54 c += ((int) a[i] * (int) b[i]);
55 }
56 return c;
57 }
58
59 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
60 usdot_prodv8qi_scalar (unsigned char *a, char *b, int c)
61 {
62 int i;
63 for (i = 0; i < 8; i++)
64 {
65 c += ((int) a[i] * (int) b[i]);
66 }
67 return c;
68 }
69
70 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
71 udot_prodv8qi_scalar (unsigned char *a, unsigned char *b, int c)
72 {
73 int i;
74 for (i = 0; i < 8; i++)
75 {
76 c += ((int) a[i] * (int) b[i]);
77 }
78 return c;
79 }
80
81 int __attribute__((noinline, noclone, optimize("no-tree-vectorize")))
82 sdot_prodv8qi_scalar (char *a, char *b, int c)
83 {
84 int i;
85 for (i = 0; i < 8; i++)
86 {
87 c += ((int) a[i] * (int) b[i]);
88 }
89 return c;
90 }
91
92 void init ()
93 {
94 int i;
95
96 for (i = 0; i < 4; i++)
97 {
98 hs1[i] = -i + 2;
99 hs2[i] = -i * 2;
100 hu1[i] = i * 3;
101 hu2[i] = i * 4;
102 }
103
104 for (i = 0; i < 8; i++)
105 {
106 qs1[i] = -i + 2;
107 qs2[i] = -i * 2;
108 qu1[i] = i * 3;
109 qu2[i] = i * 4;
110 }
111
112 }
113
114 void
115 TEST (void)
116 {
117 init ();
118 int usdot_prodv8qi_ref;
119 int sdot_prodv8qi_ref;
120 int udot_prodv8qi_ref;
121 int usdot_prodv4hi_ref;
122 int sdot_prodv4hi_ref;
123 int udot_prodv4hi_ref;
124
125 int usdot_prodv8qi_exp;
126 int sdot_prodv8qi_exp;
127 int udot_prodv8qi_exp;
128 int usdot_prodv4hi_exp;
129 int sdot_prodv4hi_exp;
130 int udot_prodv4hi_exp;
131
132 usdot_prodv8qi_ref = usdot_prodv8qi (qu1, qs1, 1);
133 usdot_prodv8qi_exp = usdot_prodv8qi_scalar (qu1, qs1, 1);
134 if (usdot_prodv8qi_ref != usdot_prodv8qi_exp)
135 abort ();
136
137 udot_prodv8qi_ref = udot_prodv8qi (qu1, qu2, 2);
138 udot_prodv8qi_exp = udot_prodv8qi_scalar (qu1, qu2, 2);
139 if (udot_prodv8qi_ref != udot_prodv8qi_exp)
140 abort ();
141
142 sdot_prodv8qi_ref = sdot_prodv8qi (qs1, qs2, 3);
143 sdot_prodv8qi_exp = sdot_prodv8qi_scalar (qs1, qs2, 3);
144 if (sdot_prodv8qi_ref != sdot_prodv8qi_exp)
145 abort ();
146
147 usdot_prodv4hi_ref = usdot_prodv4hi (hu1, hs1, 4);
148 usdot_prodv4hi_exp = usdot_prodv4hi_scalar (hu1, hs1, 4);
149 if (usdot_prodv4hi_ref != usdot_prodv4hi_exp)
150 abort ();
151
152 udot_prodv4hi_ref = udot_prodv4hi (hu1, hu2, 5);
153 udot_prodv4hi_exp = udot_prodv4hi_scalar (hu1, hu2, 5);
154 if (udot_prodv4hi_ref != udot_prodv4hi_exp)
155 abort ();
156
157 sdot_prodv4hi_ref = sdot_prodv4hi (hs1, hs2, 6);
158 sdot_prodv4hi_exp = sdot_prodv4hi_scalar (hs1, hs2, 6);
159 if (sdot_prodv4hi_ref != sdot_prodv4hi_exp)
160 abort ();
161 }