Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / ieee / fp-cmp-cond-1.c
blob4a3c4b0eee294323ff51354a502e5313532fa082
1 /* PR tree-optimization/111109 */
3 /*
4 f should return 0 if either fa and fb are a nan.
5 Rather than the value of a or b.
6 */
7 __attribute__((noipa))
8 int f(int a, int b, float fa, float fb) {
9 const _Bool c = fa < fb;
10 const _Bool c1 = fa >= fb;
11 return (c * a) | (c1 * b);
15 f1 should return 0 if either fa and fb are a nan.
16 Rather than the value of a&1 or b&1.
18 __attribute__((noipa))
19 int f1(int a, int b, float fa, float fb) {
20 const _Bool c = fa < fb;
21 const _Bool c1 = fa >= fb;
22 return (c & a) | (c1 & b);
25 #if __SIZEOF_INT__ == __SIZEOF_FLOAT__
26 typedef int v4si __attribute__ ((vector_size (1*sizeof(int))));
27 typedef float v4sf __attribute__ ((vector_size (1*sizeof(float))));
29 fvf0 should return {0} if either fa and fb are a nan.
30 Rather than the value of a or b.
32 __attribute__((noipa))
33 v4si vf0(v4si a, v4si b, v4sf fa, v4sf fb) {
34 const v4si c = fa < fb;
35 const v4si c1 = fa >= fb;
36 return (c & a) | (c1 & b);
40 #endif
42 int main(void)
44 float a = __builtin_nan("");
46 if (f(-1,-1, a, a) != 0)
47 __builtin_abort();
48 if (f(-1,-1, a, 0) != 0)
49 __builtin_abort();
50 if (f(-1,-1, 0, a) != 0)
51 __builtin_abort();
52 if (f(-1,-1, 0, 0) != -1)
53 __builtin_abort();
56 if (f1(1,1, a, a) != 0)
57 __builtin_abort();
58 if (f1(1,1, a, 0) != 0)
59 __builtin_abort();
60 if (f1(1,1, 0, a) != 0)
61 __builtin_abort();
62 if (f1(1,1, 0, 0) != 1)
63 __builtin_abort();
65 #if __SIZEOF_INT__ == __SIZEOF_FLOAT__
66 v4si b = {-1};
67 v4sf c = {a};
68 v4sf d = {0.0};
69 if (vf0(b,b, c, c)[0] != 0)
70 __builtin_abort();
71 if (vf0(b,b, c, d)[0] != 0)
72 __builtin_abort();
73 if (vf0(b,b, d, c)[0] != 0)
74 __builtin_abort();
75 if (vf0(b,b, d, d)[0] != b[0])
76 __builtin_abort();
77 #endif