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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [builtins-20.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Copyright (C) 2003  Free Software Foundation.
2
 
3
   Verify that built-in math function constant folding doesn't break
4
   anything and produces the expected results.
5
 
6
   Written by Roger Sayle, 8th June 2003.  */
7
 
8
/* { dg-do link } */
9
/* { dg-options "-O2 -ffast-math" } */
10
/* { dg-options "-O2 -ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
11
/* { dg-options "-O2 -ffast-math -std=c99" { target *-*-solaris2* } } */
12
 
13
#include "builtins-config.h"
14
 
15
extern double cos (double);
16
extern double sin (double);
17
extern double tan (double);
18
extern float cosf (float);
19
extern float sinf (float);
20
extern float tanf (float);
21
extern long double cosl (long double);
22
extern long double sinl (long double);
23
extern long double tanl (long double);
24
 
25
extern void link_error(void);
26
 
27
void test1(double x)
28
{
29
  if (cos(x) != cos(-x))
30
    link_error ();
31
 
32
  if (sin(x)/cos(x) != tan(x))
33
    link_error ();
34
 
35
  if (cos(x)/sin(x) != 1.0/tan(x))
36
    link_error ();
37
 
38
  if (tan(x)*cos(x) != sin(x))
39
    link_error ();
40
 
41
  if (cos(x)*tan(x) != sin(x))
42
    link_error ();
43
 
44
  if (sin(x)/tan(x) != cos(x))
45
    link_error ();
46
 
47
  if (tan(x)/sin(x) != 1.0/cos(x))
48
    link_error ();
49
}
50
 
51
void test2(double x, double y)
52
{
53
  if (-tan(x-y) != tan(y-x))
54
    link_error ();
55
 
56
  if (-sin(x-y) != sin(y-x))
57
    link_error ();
58
}
59
 
60
void test1f(float x)
61
{
62
  if (cosf(x) != cosf(-x))
63
    link_error ();
64
 
65
#ifdef HAVE_C99_RUNTIME
66
  if (sinf(x)/cosf(x) != tanf(x))
67
    link_error ();
68
 
69
  if (cosf(x)/sinf(x) != 1.0f/tanf(x))
70
    link_error ();
71
 
72
  if (tanf(x)*cosf(x) != sinf(x))
73
    link_error ();
74
 
75
  if (cosf(x)*tanf(x) != sinf(x))
76
    link_error ();
77
 
78
  if (sinf(x)/tanf(x) != cosf(x))
79
    link_error ();
80
 
81
  if (tanf(x)/sinf(x) != 1.0f/cosf(x))
82
    link_error ();
83
#endif
84
}
85
 
86
void test2f(float x, float y)
87
{
88
  if (-tanf(x-y) != tanf(y-x))
89
    link_error ();
90
 
91
  if (-sinf(x-y) != sinf(y-x))
92
    link_error ();
93
}
94
 
95
 
96
void test1l(long double x)
97
{
98
  if (cosl(x) != cosl(-x))
99
    link_error ();
100
 
101
#ifdef HAVE_C99_RUNTIME
102
  if (sinl(x)/cosl(x) != tanl(x))
103
    link_error ();
104
 
105
  if (cosl(x)/sinl(x) != 1.0l/tanl(x))
106
    link_error ();
107
 
108
  if (tanl(x)*cosl(x) != sinl(x))
109
    link_error ();
110
 
111
  if (cosl(x)*tanl(x) != sinl(x))
112
    link_error ();
113
 
114
  if (sinl(x)/tanl(x) != cosl(x))
115
    link_error ();
116
 
117
  if (tanl(x)/sinl(x) != 1.0l/cosl(x))
118
    link_error ();
119
#endif
120
}
121
 
122
void test2l(long double x, long double y)
123
{
124
  if (-tanl(x-y) != tanl(y-x))
125
    link_error ();
126
 
127
  if (-sinl(x-y) != sinl(y-x))
128
    link_error ();
129
}
130
 
131
int main()
132
{
133
  test1 (1.0);
134
  test2 (1.0, 2.0);
135
 
136
  test1f (1.0f);
137
  test2f (1.0f, 2.0f);
138
 
139
  test1l (1.0l);
140
  test2l (1.0l, 2.0l);
141
 
142
  return 0;
143
}
144
 

powered by: WebSVN 2.1.0

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