1 /* Like fp-cmp-4.c, but test that the cmove patterns are correct. */
4 test_isunordered(double x
, double y
, double a
, double b
)
6 return __builtin_isunordered(x
, y
) ? a
: b
;
10 test_not_isunordered(double x
, double y
, double a
, double b
)
12 return !__builtin_isunordered(x
, y
) ? a
: b
;
16 test_isless(double x
, double y
, double a
, double b
)
18 return __builtin_isless(x
, y
) ? a
: b
;
22 test_not_isless(double x
, double y
, double a
, double b
)
24 return !__builtin_isless(x
, y
) ? a
: b
;
28 test_islessequal(double x
, double y
, double a
, double b
)
30 return __builtin_islessequal(x
, y
) ? a
: b
;
34 test_not_islessequal(double x
, double y
, double a
, double b
)
36 return !__builtin_islessequal(x
, y
) ? a
: b
;
40 test_isgreater(double x
, double y
, double a
, double b
)
42 return __builtin_isgreater(x
, y
) ? a
: b
;
46 test_not_isgreater(double x
, double y
, double a
, double b
)
48 return !__builtin_isgreater(x
, y
) ? a
: b
;
52 test_isgreaterequal(double x
, double y
, double a
, double b
)
54 return __builtin_isgreaterequal(x
, y
) ? a
: b
;
58 test_not_isgreaterequal(double x
, double y
, double a
, double b
)
60 return !__builtin_isgreaterequal(x
, y
) ? a
: b
;
64 test_islessgreater(double x
, double y
, double a
, double b
)
66 return __builtin_islessgreater(x
, y
) ? a
: b
;
70 test_not_islessgreater(double x
, double y
, double a
, double b
)
72 return !__builtin_islessgreater(x
, y
) ? a
: b
;
76 one_test(double x
, double y
, int expected
,
77 double (*pos
) (double, double, double, double),
78 double (*neg
) (double, double, double, double))
80 if (((*pos
)(x
, y
, 1.0, 2.0) == 1.0) != expected
)
82 if (((*neg
)(x
, y
, 3.0, 4.0) == 4.0) != expected
)
86 #define NAN (0.0 / 0.0)
87 #define INF (1.0 / 0.0)
98 static struct try const data
[] =
100 { NAN
, NAN
, { 1, 0, 0, 0, 0, 0 } },
101 { 0.0, NAN
, { 1, 0, 0, 0, 0, 0 } },
102 { NAN
, 0.0, { 1, 0, 0, 0, 0, 0 } },
103 { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
104 { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
105 { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
106 { INF
, 0.0, { 0, 0, 0, 1, 1, 1 } },
107 { 1.0, INF
, { 0, 1, 1, 0, 0, 1 } },
108 { INF
, INF
, { 0, 0, 1, 0, 1, 0 } },
109 { 0.0, -INF
, { 0, 0, 0, 1, 1, 1 } },
110 { -INF
, 1.0, { 0, 1, 1, 0, 0, 1 } },
111 { -INF
, -INF
, { 0, 0, 1, 0, 1, 0 } },
112 { INF
, -INF
, { 0, 0, 0, 1, 1, 1 } },
113 { -INF
, INF
, { 0, 1, 1, 0, 0, 1 } },
118 double (*pos
)(double, double, double, double);
119 double (*neg
)(double, double, double, double);
122 static struct test
const tests
[] =
124 { test_isunordered
, test_not_isunordered
},
125 { test_isless
, test_not_isless
},
126 { test_islessequal
, test_not_islessequal
},
127 { test_isgreater
, test_not_isgreater
},
128 { test_isgreaterequal
, test_not_isgreaterequal
},
129 { test_islessgreater
, test_not_islessgreater
}
132 const int n
= sizeof(data
) / sizeof(data
[0]);
135 for (i
= 0; i
< n
; ++i
)
136 for (j
= 0; j
< 6; ++j
)
137 one_test (data
[i
].x
, data
[i
].y
, data
[i
].result
[j
],
138 tests
[j
].pos
, tests
[j
].neg
);