[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-8-runnable.c
blob38a1390d18e0d0a2d3d917bd5369bca4ecfc9fbd
1 /* { dg-do run } */
2 /* { dg-require-effective-target p8vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power8 -O2" } */
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <math.h>
8 #include <altivec.h>
10 #ifdef DEBUG
11 #include <stdio.h>
12 #endif
14 void abort (void);
16 int main()
18 int i;
19 vector float f_arg1;
20 vector double d_arg1;
22 vector float vec_f_expected1, vec_f_result1, vec_f_error;
23 vector double vec_d_expected1, vec_d_result1, vec_d_error;
25 /* vec_expte: float args, result */
26 f_arg1 = (vector float){1.0, 2.0, 3.0, 4.0};
27 vec_f_expected1 = (vector float){2.0, 4.0, 8.0, 16.0};
29 vec_f_result1 = vec_expte (f_arg1);
31 for (i = 0; i < 4; i++)
33 if (vec_f_expected1[i] != vec_f_result1[i])
34 #ifdef DEBUG
35 printf("ERROR vec_expte (f) result[%d]=%f != expected[%d]=%f\n",
36 i, vec_f_result1[i], i, vec_f_expected1[i]);
37 #else
38 abort();
39 #endif
42 /* vec_loge: float args, result */
43 f_arg1 = (vector float){4.0, 8.0, 16.0, 64};
44 vec_f_expected1 = (vector float){2.0, 3.0, 4.0, 6.0};
46 vec_f_result1 = vec_loge (f_arg1);
48 for (i = 0; i < 4; i++)
50 if (vec_f_expected1[i] != vec_f_result1[i])
51 #ifdef DEBUG
52 printf("ERROR vec_loge (f) result[%d]=%f != expected[%d]=%f\n",
53 i, vec_f_result1[i], i, vec_f_expected1[i]);
54 #else
55 abort();
56 #endif
59 /* vec_re: float args, result (calculate approximate reciprocal) */
60 f_arg1 = (vector float){1.0, 5.0, 4.0, 8.0};
61 vec_f_expected1 = (vector float){1.0, 0.2, 0.25, 0.125};
62 vec_f_error = (vector float){1.0, 0.2, 0.25, 0.125};
64 vec_f_result1 = vec_re (f_arg1);
66 for (i = 0; i < 4; i++)
68 vec_f_error[i] = fabs(vec_f_expected1[i] - vec_f_result1[i]);
70 if (vec_f_error[i] >= 0.0001)
71 #ifdef DEBUG
72 printf("ERROR vec_re (f) result[%d]=%f != expected[%d]=%f\n",
73 i, vec_f_result1[i], i, vec_f_expected1[i]);
74 #else
75 abort();
76 #endif
79 /* vec_re: double args, result (calculate approximate reciprocal) */
80 d_arg1 = (vector double){1.0, 8.0};
81 vec_d_expected1 = (vector double){1.0, 0.125};
82 vec_d_error = (vector double){1.0, 0.125};
84 vec_d_result1 = vec_re (d_arg1);
86 for (i = 0; i < 2; i++)
88 vec_d_error[i] = fabs(vec_d_expected1[i] - vec_d_result1[i]);
90 if (vec_d_error[i] >= 0.0001)
91 #ifdef DEBUG
92 printf("ERROR vec_re (d) result[%d]=%f != expected[%d]=%f\n",
93 i, vec_d_result1[i], i, vec_d_expected1[i]);
94 #else
95 abort();
96 #endif