Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-3-p9-runnable.c
blob35a81a7facba6bd9e361f62b967468699925e918
1 /* { dg-do run { target { powerpc64*-*-* && { lp64 && p9vector_hw } } } } */
2 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
3 /* { dg-options "-mcpu=power9 -O2" } */
5 #ifdef DEBUG
6 #include <stdio.h>
7 #endif
9 #include <altivec.h> // vector
11 void abort (void);
13 int main() {
14 int i;
15 vector float vfr, vfexpt;
16 vector unsigned short vusha;
18 /* 1.0, -2.0, 0.0, 8.5, 1.5, 0.5, 1.25, -0.25 */
19 vusha = (vector unsigned short){0B011110000000000, 0B1100000000000000,
20 0B000000000000000, 0B0100100001000000,
21 0B011111000000000, 0B0011100000000000,
22 0B011110100000000, 0B1011010000000000};
24 #ifdef DEBUG
25 printf ("Claim, source data is 8 16-bit floats:\n");
26 printf (" {1.0, -2.0, 0.0, 8.5, 1.5, 0.5, 1.25, -0.25}\n");
27 printf ("vusha = (vector unsigned short){0B011110000000000, 0B1100000000000000,\n");
28 printf (" 0B000000000000000, 0B0100100001000000,\n");
29 printf (" 0B011111000000000, 0B0011100000000000,\n");
30 printf (" 0B011110100000000, 0B1011010000000000};\n\n");
31 #endif
33 /* The ABI lists the builtins as:
35 vec_extract_fp32_from_shorth()
36 vec_extract_fp32_from_shortl()
38 GCC will also accept and map the builtin names
40 vec_extract_fp_from_shorth()
41 vec_extract_fp_from_shortl()
43 to the same builtins internally. For completeness,
44 test both builtin function names. */
46 vfexpt = (vector float){1.0, -2.0, 0.0, 8.5};
47 vfr = vec_extract_fp32_from_shorth(vusha);
49 #ifdef DEBUG
50 printf ("vec_extract_fp32_from_shorth\n");
51 for (i=0; i<4; i++)
52 printf("result[%d] = %f; expected[%d] = %f\n",
53 i, vfr[i], i, vfexpt[i]);
54 #endif
56 for (i=0; i<4; i++) {
57 if (vfr[i] != vfexpt[i])
58 abort();
61 vfexpt = (vector float){1.5, 0.5, 1.25, -0.25};
62 vfr = vec_extract_fp32_from_shortl(vusha);
64 #ifdef DEBUG
65 printf ("\nvec_extract_fp32_from_shortl\n");
66 for (i=0; i<4; i++)
67 printf("result[%d] = %f; expected[%d] = %f\n",
68 i, vfr[i], i, vfexpt[i]);
69 #endif
71 for (i=0; i<4; i++) {
72 if (vfr[i] != vfexpt[i])
73 abort();
75 vfexpt = (vector float){1.0, -2.0, 0.0, 8.5};
76 vfr = vec_extract_fp_from_shorth(vusha);
78 #ifdef DEBUG
79 printf ("vec_extract_fp_from_shorth\n");
80 for (i=0; i<4; i++)
81 printf("result[%d] = %f; expected[%d] = %f\n",
82 i, vfr[i], i, vfexpt[i]);
83 #endif
85 for (i=0; i<4; i++) {
86 if (vfr[i] != vfexpt[i])
87 abort();
90 vfexpt = (vector float){1.5, 0.5, 1.25, -0.25};
91 vfr = vec_extract_fp_from_shortl(vusha);
93 #ifdef DEBUG
94 printf ("\nvec_extract_fp_from_shortl\n");
95 for (i=0; i<4; i++)
96 printf("result[%d] = %f; expected[%d] = %f\n",
97 i, vfr[i], i, vfexpt[i]);
98 #endif
100 for (i=0; i<4; i++) {
101 if (vfr[i] != vfexpt[i])
102 abort();