gcc/ChangeLog:
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-3-p9-runnable.c
blob3197a5076e0e460009ee142a77cc1074bbbcf57e
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 vfexpt = (vector float){1.0, -2.0, 0.0, 8.5};
34 vfr = vec_extract_fp_from_shorth(vusha);
36 #ifdef DEBUG
37 printf ("vec_extract_fp_from_shorth\n");
38 for (i=0; i<4; i++)
39 printf("result[%d] = %f; expected[%d] = %f\n",
40 i, vfr[i], i, vfexpt[i]);
41 #endif
43 for (i=0; i<4; i++) {
44 if (vfr[i] != vfexpt[i])
45 abort();
48 vfexpt = (vector float){1.5, 0.5, 1.25, -0.25};
49 vfr = vec_extract_fp_from_shortl(vusha);
51 #ifdef DEBUG
52 printf ("\nvec_extract_fp_from_shortl\n");
53 for (i=0; i<4; i++)
54 printf("result[%d] = %f; expected[%d] = %f\n",
55 i, vfr[i], i, vfexpt[i]);
56 #endif
58 for (i=0; i<4; i++) {
59 if (vfr[i] != vfexpt[i])
60 abort();