Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-cond-1.c

raw
1 /* PR tree-optimization/111109 */
2
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);
12 }
13
14 /*
15 f1 should return 0 if either fa and fb are a nan.
16 Rather than the value of a&1 or b&1.
17 */
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);
23 }
24
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))));
28 /*
29 fvf0 should return {0} if either fa and fb are a nan.
30 Rather than the value of a or b.
31 */
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);
37 }
38
39
40 #endif
41
42 int main(void)
43 {
44 float a = __builtin_nan("");
45
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();
54
55
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();
64
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
78 }