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.dg/] [builtins-26.c] - Blame information for rev 414

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

Line No. Rev Author Line
1 298 jeremybenn
/* Copyright (C) 2003 Free Software Foundation.
2
 
3
   Check that constant folding of built-in math functions doesn't
4
   break anything and produces the expected results.
5
 
6
   Written by Roger Sayle, 28th June 2003.  */
7
 
8
/* { dg-do link } */
9
/* { dg-options "-O2 -ffast-math" } */
10
 
11
extern void link_error(void);
12
 
13
extern double trunc(double);
14
extern double floor(double);
15
extern double ceil(double);
16
 
17
extern float truncf(float);
18
extern float floorf(float);
19
extern float ceilf(float);
20
 
21
extern long double truncl(long double);
22
extern long double floorl(long double);
23
extern long double ceill(long double);
24
 
25
void test(double x)
26
{
27
  if (trunc (trunc (x)) != trunc (x))
28
    link_error ();
29
  if (trunc (floor (x)) != floor (x))
30
    link_error ();
31
  if (trunc (ceil (x)) != ceil (x))
32
    link_error ();
33
 
34
  if (floor (trunc (x)) != trunc (x))
35
    link_error ();
36
  if (floor (floor (x)) != floor (x))
37
    link_error ();
38
  if (floor (ceil (x)) != ceil (x))
39
    link_error ();
40
 
41
  if (ceil (trunc (x)) != trunc (x))
42
    link_error ();
43
  if (ceil (floor (x)) != floor (x))
44
    link_error ();
45
  if (ceil (ceil (x)) != ceil (x))
46
    link_error ();
47
}
48
 
49
void testf(float x)
50
{
51
  if (truncf (truncf (x)) != truncf (x))
52
    link_error ();
53
  if (truncf (floorf (x)) != floorf (x))
54
    link_error ();
55
  if (truncf (ceilf (x)) != ceilf (x))
56
    link_error ();
57
 
58
  if (floorf (truncf (x)) != truncf (x))
59
    link_error ();
60
  if (floorf (floorf (x)) != floorf (x))
61
    link_error ();
62
  if (floorf (ceilf (x)) != ceilf (x))
63
    link_error ();
64
 
65
  if (ceilf (truncf (x)) != truncf (x))
66
    link_error ();
67
  if (ceilf (floorf (x)) != floorf (x))
68
    link_error ();
69
  if (ceilf (ceilf (x)) != ceilf (x))
70
    link_error ();
71
}
72
 
73
void testl(long double x)
74
{
75
  if (truncl (truncl (x)) != truncl (x))
76
    link_error ();
77
  if (truncl (floorl (x)) != floorl (x))
78
    link_error ();
79
  if (truncl (ceill (x)) != ceill (x))
80
    link_error ();
81
 
82
  if (floorl (truncl (x)) != truncl (x))
83
    link_error ();
84
  if (floorl (floorl (x)) != floorl (x))
85
    link_error ();
86
  if (floorl (ceill (x)) != ceill (x))
87
    link_error ();
88
 
89
  if (ceill (truncl (x)) != truncl (x))
90
    link_error ();
91
  if (ceill (floorl (x)) != floorl (x))
92
    link_error ();
93
  if (ceill (ceill (x)) != ceill (x))
94
    link_error ();
95
}
96
 
97
 
98
int main()
99
{
100
  test (3.2);
101
  testf (3.2f);
102
  testl (3.2l);
103
  return 0;
104
}
105
 

powered by: WebSVN 2.1.0

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