Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.target / spu / dfcgt-nan.c
blob18ce0135638c74fa4771caf9a237198b486aea14
1 /* { dg-do compile } */
2 /* { dg-options "-march=celledp -O1" } */
3 /* { dg-final { scan-assembler "dfceq" } } */
5 /* GCC previously transformed an "a <= b" test into "! (a > b)" when
6 compiling with -march=celledp, so that the dfcgt instruction can be
7 used to implement the comparison.
9 However, this transformation violates the IEEE-754 standard in the
10 presence of NaN values. If either a or b is a NaN, a <= b should
11 evaluate to false according to IEEE rules. However, after the
12 transformation, a > b as implemented by dfcgt itself returns false,
13 so the transformed test returns true.
15 Note that the equivalent transformation is valid for single-
16 precision floating-point values on the Cell SPU, because the format
17 does not have NaNs. It is invalid for double-precision, even on
18 Cell, however. */
20 int test (double a, double b) __attribute__ ((noinline));
21 int test (double a, double b)
23 return a <= b;
26 int main (void)
28 double x = 0.0;
29 double y = 0.0/0.0;
30 return test (x, y);