OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [spu/] [dfcgt-nan.c] - Blame information for rev 859

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 327 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-march=celledp -O1" } */
3
/* { dg-final { scan-assembler "dfceq" } } */
4
 
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.
8
 
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.
14
 
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.  */
19
 
20
int test (double a, double b) __attribute__ ((noinline));
21
int test (double a, double b)
22
{
23
  return a <= b;
24
}
25
 
26
int main (void)
27
{
28
  double x = 0.0;
29
  double y = 0.0/0.0;
30
  return test (x, y);
31
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.