5 /* Like fp-cmp-4.c, but test that the cmove patterns are correct. */
8 test_isunordered(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
10 return __builtin_isunordered(x
, y
) ? a
: b
;
14 test_not_isunordered(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
16 return !__builtin_isunordered(x
, y
) ? a
: b
;
20 test_isless(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
22 return __builtin_isless(x
, y
) ? a
: b
;
26 test_not_isless(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
28 return !__builtin_isless(x
, y
) ? a
: b
;
32 test_islessequal(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
34 return __builtin_islessequal(x
, y
) ? a
: b
;
38 test_not_islessequal(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
40 return !__builtin_islessequal(x
, y
) ? a
: b
;
44 test_isgreater(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
46 return __builtin_isgreater(x
, y
) ? a
: b
;
50 test_not_isgreater(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
52 return !__builtin_isgreater(x
, y
) ? a
: b
;
56 test_isgreaterequal(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
58 return __builtin_isgreaterequal(x
, y
) ? a
: b
;
62 test_not_isgreaterequal(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
64 return !__builtin_isgreaterequal(x
, y
) ? a
: b
;
68 test_islessgreater(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
70 return __builtin_islessgreater(x
, y
) ? a
: b
;
74 test_not_islessgreater(FLOAT x
, FLOAT y
, FLOAT a
, FLOAT b
)
76 return !__builtin_islessgreater(x
, y
) ? a
: b
;
80 one_test(FLOAT x
, FLOAT y
, int expected
,
81 FLOAT (*pos
) (FLOAT
, FLOAT
, FLOAT
, FLOAT
),
82 FLOAT (*neg
) (FLOAT
, FLOAT
, FLOAT
, FLOAT
))
84 if (((*pos
)(x
, y
, 1.0, 2.0) == 1.0) != expected
)
86 if (((*neg
)(x
, y
, 3.0, 4.0) == 4.0) != expected
)
90 #define NAN (0.0 / 0.0)
91 #define INF (1.0 / 0.0)
102 static struct try const data
[] =
104 { NAN
, NAN
, { 1, 0, 0, 0, 0, 0 } },
105 { 0.0, NAN
, { 1, 0, 0, 0, 0, 0 } },
106 { NAN
, 0.0, { 1, 0, 0, 0, 0, 0 } },
107 { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
108 { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
109 { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
110 { INF
, 0.0, { 0, 0, 0, 1, 1, 1 } },
111 { 1.0, INF
, { 0, 1, 1, 0, 0, 1 } },
112 { INF
, INF
, { 0, 0, 1, 0, 1, 0 } },
113 { 0.0, -INF
, { 0, 0, 0, 1, 1, 1 } },
114 { -INF
, 1.0, { 0, 1, 1, 0, 0, 1 } },
115 { -INF
, -INF
, { 0, 0, 1, 0, 1, 0 } },
116 { INF
, -INF
, { 0, 0, 0, 1, 1, 1 } },
117 { -INF
, INF
, { 0, 1, 1, 0, 0, 1 } },
122 FLOAT (*pos
)(FLOAT
, FLOAT
, FLOAT
, FLOAT
);
123 FLOAT (*neg
)(FLOAT
, FLOAT
, FLOAT
, FLOAT
);
126 static struct test
const tests
[] =
128 { test_isunordered
, test_not_isunordered
},
129 { test_isless
, test_not_isless
},
130 { test_islessequal
, test_not_islessequal
},
131 { test_isgreater
, test_not_isgreater
},
132 { test_isgreaterequal
, test_not_isgreaterequal
},
133 { test_islessgreater
, test_not_islessgreater
}
136 const int n
= sizeof(data
) / sizeof(data
[0]);
139 for (i
= 0; i
< n
; ++i
)
140 for (j
= 0; j
< 6; ++j
)
141 one_test (data
[i
].x
, data
[i
].y
, data
[i
].result
[j
],
142 tests
[j
].pos
, tests
[j
].neg
);