Handle T_HRESULT types in CodeView records
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vec-init-5.c
blob87e1e4dedf0d37fec2838f85fbe998aa79d6c10b
1 /* { dg-do run } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-O2 -mvsx" } */
5 #include <stdlib.h>
6 #include <stddef.h>
7 #include <altivec.h>
9 #define ELEMENTS 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 127, -1, -128
10 #define SPLAT 0x12
12 vector signed char sv = (vector signed char) { ELEMENTS };
13 vector signed char splat = (vector signed char) { SPLAT, SPLAT, SPLAT, SPLAT,
14 SPLAT, SPLAT, SPLAT, SPLAT,
15 SPLAT, SPLAT, SPLAT, SPLAT,
16 SPLAT, SPLAT, SPLAT, SPLAT };
17 vector signed char sv_global, sp_global;
18 static vector signed char sv_static, sp_static;
19 static signed char expected[] = { ELEMENTS };
20 static signed char splat_expected = SPLAT;
22 extern void check (vector signed char a)
23 __attribute__((__noinline__));
25 extern void check_splat (vector signed char a)
26 __attribute__((__noinline__));
28 extern vector signed char pack_reg (signed char a, signed char b,
29 signed char c, signed char d,
30 signed char e, signed char f,
31 signed char g, signed char h,
32 signed char i, signed char j,
33 signed char k, signed char l,
34 signed char m, signed char n,
35 signed char o, signed char p)
36 __attribute__((__noinline__));
38 extern vector signed char pack_from_ptr (signed char *p_a, signed char *p_b,
39 signed char *p_c, signed char *p_d,
40 signed char *p_e, signed char *p_f,
41 signed char *p_g, signed char *p_h,
42 signed char *p_i, signed char *p_j,
43 signed char *p_k, signed char *p_l,
44 signed char *p_m, signed char *p_n,
45 signed char *p_o, signed char *p_p)
46 __attribute__((__noinline__));
48 extern vector signed char pack_const (void)
49 __attribute__((__noinline__));
51 extern void pack_ptr (vector signed char *q,
52 signed char a, signed char b, signed char c, signed char d,
53 signed char e, signed char f, signed char g, signed char h,
54 signed char i, signed char j, signed char k, signed char l,
55 signed char m, signed char n, signed char o, signed char p)
56 __attribute__((__noinline__));
58 extern void pack_static (signed char a, signed char b, signed char c, signed char d,
59 signed char e, signed char f, signed char g, signed char h,
60 signed char i, signed char j, signed char k, signed char l,
61 signed char m, signed char n, signed char o, signed char p)
62 __attribute__((__noinline__));
64 extern void pack_global (signed char a, signed char b, signed char c, signed char d,
65 signed char e, signed char f, signed char g, signed char h,
66 signed char i, signed char j, signed char k, signed char l,
67 signed char m, signed char n, signed char o, signed char p)
68 __attribute__((__noinline__));
70 extern vector signed char splat_reg (signed char a)
71 __attribute__((__noinline__));
73 extern vector signed char splat_from_ptr (signed char *p_a)
74 __attribute__((__noinline__));
76 extern vector signed char splat_const (void)
77 __attribute__((__noinline__));
79 extern void splat_ptr (vector signed char *p, signed char a)
80 __attribute__((__noinline__));
82 extern void splat_static (signed char a)
83 __attribute__((__noinline__));
85 extern void splat_global (signed char a)
86 __attribute__((__noinline__));
88 void
89 check (vector signed char a)
91 size_t i;
93 for (i = 0; i < 16; i++)
94 if (vec_extract (a, i) != expected[i])
95 abort ();
98 void
99 check_splat (vector signed char a)
101 size_t i;
103 for (i = 0; i < 16; i++)
104 if (vec_extract (a, i) != SPLAT)
105 abort ();
108 vector signed char
109 pack_reg (signed char a, signed char b, signed char c, signed char d,
110 signed char e, signed char f, signed char g, signed char h,
111 signed char i, signed char j, signed char k, signed char l,
112 signed char m, signed char n, signed char o, signed char p)
114 return (vector signed char) { a, b, c, d, e, f, g, h,
115 i, j, k, l, m, n, o, p };
118 vector signed char
119 pack_from_ptr (signed char *p_a, signed char *p_b, signed char *p_c, signed char *p_d,
120 signed char *p_e, signed char *p_f, signed char *p_g, signed char *p_h,
121 signed char *p_i, signed char *p_j, signed char *p_k, signed char *p_l,
122 signed char *p_m, signed char *p_n, signed char *p_o, signed char *p_p)
124 return (vector signed char) { *p_a, *p_b, *p_c, *p_d,
125 *p_e, *p_f, *p_g, *p_h,
126 *p_i, *p_j, *p_k, *p_l,
127 *p_m, *p_n, *p_o, *p_p };
131 vector signed char
132 pack_const (void)
134 return (vector signed char) { ELEMENTS };
137 void
138 pack_ptr (vector signed char *q,
139 signed char a, signed char b, signed char c, signed char d,
140 signed char e, signed char f, signed char g, signed char h,
141 signed char i, signed char j, signed char k, signed char l,
142 signed char m, signed char n, signed char o, signed char p)
144 *q = (vector signed char) { a, b, c, d, e, f, g, h,
145 i, j, k, l, m, n, o, p };
148 void
149 pack_static (signed char a, signed char b, signed char c, signed char d,
150 signed char e, signed char f, signed char g, signed char h,
151 signed char i, signed char j, signed char k, signed char l,
152 signed char m, signed char n, signed char o, signed char p)
154 sv_static = (vector signed char) { a, b, c, d, e, f, g, h,
155 i, j, k, l, m, n, o, p };
158 void
159 pack_global (signed char a, signed char b, signed char c, signed char d,
160 signed char e, signed char f, signed char g, signed char h,
161 signed char i, signed char j, signed char k, signed char l,
162 signed char m, signed char n, signed char o, signed char p)
164 sv_global = (vector signed char) { a, b, c, d, e, f, g, h,
165 i, j, k, l, m, n, o, p };
168 vector signed char
169 splat_reg (signed char a)
171 return (vector signed char) { a, a, a, a, a, a, a, a,
172 a, a, a, a, a, a, a, a };
175 vector signed char
176 splat_from_ptr (signed char *p_a)
178 return (vector signed char) { *p_a, *p_a, *p_a, *p_a,
179 *p_a, *p_a, *p_a, *p_a,
180 *p_a, *p_a, *p_a, *p_a,
181 *p_a, *p_a, *p_a, *p_a };
184 vector signed char
185 splat_const (void)
187 return (vector signed char) { SPLAT, SPLAT, SPLAT, SPLAT,
188 SPLAT, SPLAT, SPLAT, SPLAT,
189 SPLAT, SPLAT, SPLAT, SPLAT,
190 SPLAT, SPLAT, SPLAT, SPLAT };
193 void
194 splat_ptr (vector signed char *p, signed char a)
196 *p = (vector signed char) { a, a, a, a, a, a, a, a,
197 a, a, a, a, a, a, a, a };
200 void
201 splat_static (signed char a)
203 sp_static = (vector signed char) { a, a, a, a, a, a, a, a,
204 a, a, a, a, a, a, a, a };
207 void
208 splat_global (signed char a)
210 sp_global = (vector signed char) { a, a, a, a, a, a, a, a,
211 a, a, a, a, a, a, a, a };
214 int main (void)
216 vector signed char sv2, sv3;
218 check (sv);
220 check (pack_reg (ELEMENTS));
222 check (pack_from_ptr (&expected[0], &expected[1], &expected[2],
223 &expected[3], &expected[4], &expected[5],
224 &expected[6], &expected[7], &expected[8],
225 &expected[9], &expected[10], &expected[11],
226 &expected[12], &expected[13], &expected[14],
227 &expected[15]));
229 check (pack_const ());
231 pack_ptr (&sv2, ELEMENTS);
232 check (sv2);
234 pack_static (ELEMENTS);
235 check (sv_static);
237 pack_global (ELEMENTS);
238 check (sv_global);
240 check_splat (splat);
242 check_splat (splat_reg (SPLAT));
244 check_splat (splat_from_ptr (&splat_expected));
246 check_splat (splat_const ());
248 splat_ptr (&sv2, SPLAT);
249 check_splat (sv2);
251 splat_static (SPLAT);
252 check_splat (sp_static);
254 splat_global (SPLAT);
255 check_splat (sp_global);
257 return 0;