Use conditional internal functions in if-conversion
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / altivec-1-runnable.c
blobbb913d2d5717259b6e4fd85c9c8b423d5722482e
1 /* { dg-do compile { target powerpc*-*-* } } */
2 /* { dg-require-effective-target powerpc_altivec_ok } */
3 /* { dg-options "-maltivec" } */
5 #include <altivec.h>
7 #ifdef DEBUG
8 #include <stdio.h>
9 #endif
11 /* Endian considerations: The "high" half of a vector with n elements is the
12 first n/2 elements of the vector. For little endian, these elements are in
13 the rightmost half of the vector. For big endian, these elements are in the
14 leftmost half of the vector. */
17 void abort (void);
19 int main ()
21 int i;
22 vector bool short vec_bs_arg;
23 vector bool short vec_bs_result, vec_bs_expected;
24 vector bool int vec_bi_arg;
25 vector bool int vec_bi_result, vec_bi_expected;
26 vector bool char vec_bc_arg;
27 vector bool char vec_bc_result, vec_bc_expected;
28 vector signed short vec_ss_arg;
29 vector signed short vec_ss_result, vec_ss_expected;
30 vector signed int vec_si_arg;
31 vector signed int vec_si_result, vec_si_expected;
32 vector signed char vec_sc_arg;
33 vector signed char vec_sc_result, vec_sc_expected;
34 vector float vec_float_arg;
35 vector double vec_double_result, vec_double_expected;
36 vector pixel vec_pixel_arg;
37 vector unsigned int vec_ui_result, vec_ui_expected;
39 union conv {
40 double d;
41 unsigned long long l;
42 } conv_exp, conv_val;
44 vec_bs_arg = (vector bool short){ 0, 101, 202, 303,
45 404, 505, 606, 707 };
46 vec_bi_expected = (vector bool int){ 0, 101, 202, 303 };
48 vec_bi_result = vec_unpackh (vec_bs_arg);
50 for (i = 0; i < 4; i++) {
51 if (vec_bi_expected[i] != vec_bi_result[i])
52 #if DEBUG
53 printf("ERROR: vec_unpackh(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n",
54 i, vec_bi_expected[i], i, vec_bi_result[i]);
55 #else
56 abort();
57 #endif
60 vec_bi_expected = (vector bool int){ 404, 505, 606, 707 };
61 vec_bi_result = vec_unpackl (vec_bs_arg);
63 for (i = 0; i < 4; i++) {
64 if (vec_bi_expected[i] != vec_bi_result[i])
65 #if DEBUG
66 printf("ERROR: vec_unpackl(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n",
67 i, vec_bi_expected[i], i, vec_bi_result[i]);
68 #else
69 abort();
70 #endif
74 vec_ss_arg = (vector signed short){ 0, 101, 202, 303,
75 404, 505, 606, 707 };
76 vec_si_expected = (vector signed int){ 0, 101, 202, 303 };
78 vec_si_result = vec_unpackh (vec_ss_arg);
80 for (i = 0; i < 4; i++) {
81 if (vec_si_expected[i] != vec_si_result[i])
82 #if DEBUG
83 printf("ERROR: vec_unpackh(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n",
84 i, vec_si_expected[i], i, vec_si_result[i]);
85 #else
86 abort();
87 #endif
90 vec_si_expected = (vector signed int){ 404, 505, 606, 707 };
92 vec_si_result = vec_unpackl (vec_ss_arg);
94 for (i = 0; i < 4; i++) {
95 if (vec_si_expected[i] != vec_si_result[i])
96 #if DEBUG
97 printf("ERROR: vec_unpackl(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n",
98 i, vec_si_expected[i], i, vec_si_result[i]);
99 #else
100 abort();
101 #endif
105 vec_pixel_arg = (vector pixel){ 0x0, 0x65, 0xca, 0x12f,
106 0x194, 0x1f9, 0x25e, 0x2c3 };
107 vec_ui_expected = (vector unsigned int){ 0x0, 0x305, 0x60a, 0x90f };
109 vec_ui_result = vec_unpackh (vec_pixel_arg);
111 for (i = 0; i < 4; i++) {
112 if (vec_ui_expected[i] != vec_ui_result[i])
113 #if DEBUG
114 printf("ERROR: vec_unpackh(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n",
115 i, vec_ui_expected[i], i, vec_ui_result[i]);
116 #else
117 abort();
118 #endif
121 vec_ui_expected = (vector unsigned int){ 0xc14, 0xf19, 0x121e, 0x1603 };
123 vec_ui_result = vec_unpackl (vec_pixel_arg);
125 for (i = 0; i < 4; i++) {
126 if (vec_ui_expected[i] != vec_ui_result[i])
127 #if DEBUG
128 printf("ERROR: vec_unpackl(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n",
129 i, vec_ui_expected[i], i, vec_ui_result[i]);
130 #else
131 abort();
132 #endif
136 vec_bc_arg = (vector bool char){ 0, 1, 0, 1, 0, 1, 0, 1,
137 0, 0, 1, 1, 0, 0, 1, 1 };
139 vec_bs_expected = (vector bool short){ 0, 1, 0, 1, 0, 1, 0, 1 };
141 vec_bs_result = vec_unpackh (vec_bc_arg);
143 for (i = 0; i < 8; i++) {
144 if (vec_bs_expected[i] != vec_bs_result[i])
145 #if DEBUG
146 printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
147 i, vec_bs_expected[i], i, vec_bs_result[i]);
148 #else
149 abort();
150 #endif
153 vec_bs_expected = (vector bool short){ 0, 0, 1, 1, 0, 0, 1, 1 };
155 vec_bs_result = vec_unpackl (vec_bc_arg);
157 for (i = 0; i < 8; i++) {
158 if (vec_bs_expected[i] != vec_bs_result[i])
159 #if DEBUG
160 printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
161 i, vec_bs_expected[i], i, vec_bs_result[i]);
162 #else
163 abort();
164 #endif
167 vec_bs_expected = (vector bool short){ 0, 0, 1, 1, 0, 0, 1, 1 };
169 vec_bs_result = vec_unpackl (vec_bc_arg);
171 for (i = 0; i < 8; i++) {
172 if (vec_bs_expected[i] != vec_bs_result[i])
173 #if DEBUG
174 printf("ERROR: vec_unpackl(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
175 i, vec_bs_expected[i], i, vec_bs_result[i]);
176 #else
177 abort();
178 #endif
182 vec_sc_arg = (vector signed char){ 0, 1, 2, 3, 4, 5, 6, 7,
183 8, 9, 10, 11, 12, 13, 14, 15 };
185 vec_ss_expected = (vector signed short){ 0, 1, 2, 3, 4, 5, 6, 7 };
187 vec_ss_result = vec_unpackh (vec_sc_arg);
189 for (i = 0; i < 8; i++) {
190 if (vec_ss_expected[i] != vec_ss_result[i])
191 #if DEBUG
192 printf("ERROR: vec_unpackh(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n",
193 i, vec_ss_expected[i], i, vec_ss_result[i]);
194 #else
195 abort();
196 #endif
199 vec_ss_expected = (vector signed short){ 8, 9, 10, 11, 12, 13, 14, 15 };
201 vec_ss_result = vec_unpackl (vec_sc_arg);
203 for (i = 0; i < 8; i++) {
204 if (vec_ss_expected[i] != vec_ss_result[i])
205 #if DEBUG
206 printf("ERROR: vec_unpackl(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n",
207 i, vec_ss_expected[i], i, vec_ss_result[i]);
208 #else
209 abort();
210 #endif
214 vec_float_arg = (vector float){ 0.0, 1.5, 2.5, 3.5 };
216 vec_double_expected = (vector double){ 0.0, 1.5 };
218 vec_double_result = vec_unpackh (vec_float_arg);
220 for (i = 0; i < 2; i++) {
221 if (vec_double_expected[i] != vec_double_result[i])
223 #if DEBUG
224 printf("ERROR: vec_unpackh(), vec_double_expected[%d] = %f does not match vec_double_result[%d] = %f\n",
225 i, vec_double_expected[i], i, vec_double_result[i]);
226 conv_val.d = vec_double_result[i];
227 conv_exp.d = vec_double_expected[i];
228 printf(" vec_unpackh(), vec_double_expected[%d] = 0x%llx does not match vec_double_result[%d] = 0x%llx\n",
229 i, conv_exp.l, i,conv_val.l);
230 #else
231 abort();
232 #endif
236 vec_double_expected = (vector double){ 2.5, 3.5 };
238 vec_double_result = vec_unpackl (vec_float_arg);
240 for (i = 0; i < 2; i++) {
241 if (vec_double_expected[i] != vec_double_result[i])
243 #if DEBUG
244 printf("ERROR: vec_unpackl() vec_double_expected[%d] = %f does not match vec_double_result[%d] = %f\n",
245 i, vec_double_expected[i], i, vec_double_result[i]);
246 conv_val.d = vec_double_result[i];
247 conv_exp.d = vec_double_expected[i];
248 printf(" vec_unpackh(), vec_double_expected[%d] = 0x%llx does not match vec_double_result[%d] = 0x%llx\n",
249 i, conv_exp.l, i,conv_val.l);
250 #else
251 abort();
252 #endif
256 return 0;