1 /* { dg-do run { target { powerpc*-*-linux* } } } */
2 /* { dg-require-effective-target ppc_float128_sw } */
3 /* { dg-options "-mvsx -O2" } */
4 
5 #include <stddef.h>
6 #include <stdlib.h>
7 
8 #ifndef TYPE
9 #define TYPE __float128
10 #define NAN __builtin_nanq ("")
11 #define SNAN __builtin_nansq ("")
12 #else
13 #define NAN __builtin_nan ("")
14 #define SNAN __builtin_nans ("")
15 #endif
16 
17 extern void check (TYPE a,
18 		   TYPE b,
19 		   int eq,
20 		   int ne,
21 		   int lt,
22 		   int le,
23 		   int gt,
24 		   int ge,
25 		   int i_lt,
26 		   int i_le,
27 		   int i_gt,
28 		   int i_ge,
29 		   int i_lg,
30 		   int i_un) __attribute__((__noinline__));
31 
32 void
check(TYPE a,TYPE b,int eq,int ne,int lt,int le,int gt,int ge,int i_lt,int i_le,int i_gt,int i_ge,int i_lg,int i_un)33 check (TYPE a,
34        TYPE b,
35        int eq,
36        int ne,
37        int lt,
38        int le,
39        int gt,
40        int ge,
41        int i_lt,
42        int i_le,
43        int i_gt,
44        int i_ge,
45        int i_lg,
46        int i_un)
47 {
48   if (eq != (a == b))
49     abort ();
50 
51   if (ne != (a != b))
52     abort ();
53 
54   if (lt != (a < b))
55     abort ();
56 
57   if (le != (a <= b))
58     abort ();
59 
60   if (gt != (a > b))
61     abort ();
62 
63   if (ge != (a >= b))
64     abort ();
65 
66   if (i_lt != __builtin_isless (a, b))
67     abort ();
68 
69   if (i_le != __builtin_islessequal (a, b))
70     abort ();
71 
72   if (i_gt != __builtin_isgreater (a, b))
73     abort ();
74 
75   if (i_ge != __builtin_isgreaterequal (a, b))
76     abort ();
77 
78   if (i_lg != __builtin_islessgreater (a, b))
79     abort ();
80 
81   if (i_un != __builtin_isunordered (a, b))
82     abort ();
83 }
84 
main(void)85 int main (void)
86 {
87   TYPE one   = (TYPE) +1.0;
88   TYPE two   = (TYPE) +2.0;
89   TYPE pzero = (TYPE) +0.0;
90   TYPE mzero = (TYPE) -0.0;
91   TYPE nan   = (TYPE) NAN;
92   TYPE snan  = (TYPE) SNAN;
93 
94   check (one,   two,   0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0);
95   check (one,   one,   1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0);
96   check (one,   pzero, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0);
97   check (mzero, pzero, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0);
98   check (nan,   one,   0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
99   check (one,   nan,   0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
100   check (nan,   nan,   0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
101   check (snan,  one,   0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
102   check (one,   snan,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
103   check (snan,  nan,   0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
104   check (nan,   snan,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
105   return 0;
106 }
107