1 /* Like fp-cmp-4.c, but test that the setcc patterns are correct. */
4 test_isunordered(double x
, double y
)
6 return __builtin_isunordered(x
, y
);
10 test_not_isunordered(double x
, double y
)
12 return !__builtin_isunordered(x
, y
);
16 test_isless(double x
, double y
)
18 return __builtin_isless(x
, y
);
22 test_not_isless(double x
, double y
)
24 return !__builtin_isless(x
, y
);
28 test_islessequal(double x
, double y
)
30 return __builtin_islessequal(x
, y
);
34 test_not_islessequal(double x
, double y
)
36 return !__builtin_islessequal(x
, y
);
40 test_isgreater(double x
, double y
)
42 return __builtin_isgreater(x
, y
);
46 test_not_isgreater(double x
, double y
)
48 return !__builtin_isgreater(x
, y
);
52 test_isgreaterequal(double x
, double y
)
54 return __builtin_isgreaterequal(x
, y
);
58 test_not_isgreaterequal(double x
, double y
)
60 return !__builtin_isgreaterequal(x
, y
);
64 test_islessgreater(double x
, double y
)
66 return __builtin_islessgreater(x
, y
);
70 test_not_islessgreater(double x
, double y
)
72 return !__builtin_islessgreater(x
, y
);
76 one_test(double x
, double y
, int expected
,
77 int (*pos
) (double, double), int (*neg
) (double, double))
79 if ((*pos
)(x
, y
) != expected
)
81 if ((*neg
)(x
, y
) != !expected
)
85 #define NAN (0.0 / 0.0)
96 static struct try const data
[] =
98 { NAN
, NAN
, { 1, 0, 0, 0, 0, 0 } },
99 { 0.0, NAN
, { 1, 0, 0, 0, 0, 0 } },
100 { NAN
, 0.0, { 1, 0, 0, 0, 0, 0 } },
101 { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
102 { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
103 { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
108 int (*pos
)(double, double);
109 int (*neg
)(double, double);
112 static struct test
const tests
[] =
114 { test_isunordered
, test_not_isunordered
},
115 { test_isless
, test_not_isless
},
116 { test_islessequal
, test_not_islessequal
},
117 { test_isgreater
, test_not_isgreater
},
118 { test_isgreaterequal
, test_not_isgreaterequal
},
119 { test_islessgreater
, test_not_islessgreater
}
122 const int n
= sizeof(data
) / sizeof(data
[0]);
125 for (i
= 0; i
< n
; ++i
)
126 for (j
= 0; j
< 6; ++j
)
127 one_test (data
[i
].x
, data
[i
].y
, data
[i
].result
[j
],
128 tests
[j
].pos
, tests
[j
].neg
);