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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [arm/] [fp16-rounding-alt-1.c] - Blame information for rev 327

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

Line No. Rev Author Line
1 313 jeremybenn
/* Test intermediate rounding of double to float and then to __fp16, using
2
   an example of a number that would round differently if it went directly
3
   from double to __fp16.  */
4
 
5
/* { dg-do run } */
6
/* { dg-options "-mfp16-format=alternative" } */
7
 
8
#include <stdlib.h>
9
 
10
/* The original double value.  */
11
#define ORIG 0x1.0020008p0
12
 
13
/* The expected (double)((__fp16)((float)ORIG)) value.  */
14
#define ROUNDED 0x1.0000000p0
15
 
16
typedef union u {
17
  __fp16 f;
18
  unsigned short h;
19
} ufh;
20
 
21
ufh s = { ORIG };
22
ufh r = { ROUNDED };
23
 
24
double d = ORIG;
25
 
26
int
27
main (void)
28
{
29
  ufh x;
30
 
31
  /* Test that the rounding is correct for static initializers.  */
32
  if (s.h != r.h)
33
    abort ();
34
 
35
  /* Test that the rounding is correct for a casted constant expression
36
     not in a static initializer.  */
37
  x.f = (__fp16)ORIG;
38
  if (x.h != r.h)
39
    abort ();
40
 
41
  /* Test that the rounding is correct for a runtime conversion.  */
42
  x.f = (__fp16)d;
43
  if (x.h != r.h)
44
    abort ();
45
 
46
  return 0;
47
}

powered by: WebSVN 2.1.0

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