2018-03-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / float128-hw11.c
blob7bd9b81427a774648a9e3fd8ddbe1868c4e31f54
1 /* { dg-do run { target { powerpc*-*-* && lp64 } } } */
2 /* { dg-require-effective-target p9vector_hw } */
3 /* { dg-options "-mpower9-vector -O2" } */
5 #define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
6 #define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
8 #include <math.h>
9 #include <stdlib.h>
10 #include <stddef.h>
12 extern _Float128 roundf128 (_Float128);
13 extern _Float128 floorf128 (_Float128);
14 extern _Float128 ceilf128 (_Float128);
15 extern _Float128 truncf128 (_Float128);
17 static const struct {
18 _Float128 value;
19 _Float128 exp_round;
20 _Float128 exp_floor;
21 _Float128 exp_ceil;
22 _Float128 exp_trunc;
23 } a[] = {
24 { -2.0Q, -2.0Q, -2.0Q, -2.0Q, -2.0Q },
25 { -1.7Q, -2.0Q, -2.0Q, -1.0Q, -1.0Q },
26 { -1.5Q, -2.0Q, -2.0Q, -1.0Q, -1.0Q },
27 { -1.3Q, -1.0Q, -2.0Q, -1.0Q, -1.0Q },
28 { +0.0Q, +0.0Q, +0.0Q, +0.0Q, +0.0Q },
29 { +1.3Q, +1.0Q, +1.0Q, +2.0Q, +1.0Q },
30 { +1.5Q, +2.0Q, +1.0Q, +2.0Q, +1.0Q },
31 { +1.7Q, +2.0Q, +1.0Q, +2.0Q, +1.0Q },
32 { +2.0Q, +2.0Q, +2.0Q, +2.0Q, +2.0Q }
35 int
36 main (void)
38 size_t i;
39 _Float128 v;
41 for (i = 0; i < sizeof (a) / sizeof (a[0]); i++)
43 v = a[i].value;
44 if (roundf128 (v) != a[i].exp_round)
45 abort ();
47 if (floorf128 (v) != a[i].exp_floor)
48 abort ();
50 if (ceilf128 (v) != a[i].exp_ceil)
51 abort ();
53 if (truncf128 (v) != a[i].exp_trunc)
54 abort ();
57 return 0;