Debian Codegraph @

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

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