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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.dg/] [builtins-20.c] - Blame information for rev 20

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

Line No. Rev Author Line
1 12 jlechner
/* 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
 
12
#include "builtins-config.h"
13
 
14
extern double cos (double);
15
extern double sin (double);
16
extern double tan (double);
17
extern float cosf (float);
18
extern float sinf (float);
19
extern float tanf (float);
20
extern long double cosl (long double);
21
extern long double sinl (long double);
22
extern long double tanl (long double);
23
 
24
extern void link_error(void);
25
 
26
void test1(double x)
27
{
28
  if (cos(x) != cos(-x))
29
    link_error ();
30
 
31
  if (sin(x)/cos(x) != tan(x))
32
    link_error ();
33
 
34
  if (cos(x)/sin(x) != 1.0/tan(x))
35
    link_error ();
36
 
37
  if (tan(x)*cos(x) != sin(x))
38
    link_error ();
39
 
40
  if (cos(x)*tan(x) != sin(x))
41
    link_error ();
42
}
43
 
44
void test2(double x, double y)
45
{
46
  if (-tan(x-y) != tan(y-x))
47
    link_error ();
48
 
49
  if (-sin(x-y) != sin(y-x))
50
    link_error ();
51
}
52
 
53
void test1f(float x)
54
{
55
  if (cosf(x) != cosf(-x))
56
    link_error ();
57
 
58
#ifdef HAVE_C99_RUNTIME
59
  if (sinf(x)/cosf(x) != tanf(x))
60
    link_error ();
61
 
62
  if (cosf(x)/sinf(x) != 1.0f/tanf(x))
63
    link_error ();
64
 
65
  if (tanf(x)*cosf(x) != sinf(x))
66
    link_error ();
67
 
68
  if (cosf(x)*tanf(x) != sinf(x))
69
    link_error ();
70
#endif
71
}
72
 
73
void test2f(float x, float y)
74
{
75
  if (-tanf(x-y) != tanf(y-x))
76
    link_error ();
77
 
78
  if (-sinf(x-y) != sinf(y-x))
79
    link_error ();
80
}
81
 
82
 
83
void test1l(long double x)
84
{
85
  if (cosl(x) != cosl(-x))
86
    link_error ();
87
 
88
#ifdef HAVE_C99_RUNTIME
89
  if (sinl(x)/cosl(x) != tanl(x))
90
    link_error ();
91
 
92
  if (cosl(x)/sinl(x) != 1.0l/tanl(x))
93
    link_error ();
94
 
95
  if (tanl(x)*cosl(x) != sinl(x))
96
    link_error ();
97
 
98
  if (cosl(x)*tanl(x) != sinl(x))
99
    link_error ();
100
#endif
101
}
102
 
103
void test2l(long double x, long double y)
104
{
105
  if (-tanl(x-y) != tanl(y-x))
106
    link_error ();
107
 
108
  if (-sinl(x-y) != sinl(y-x))
109
    link_error ();
110
}
111
 
112
int main()
113
{
114
  test1 (1.0);
115
  test2 (1.0, 2.0);
116
 
117
  test1f (1.0f);
118
  test2f (1.0f, 2.0f);
119
 
120
  test1l (1.0l);
121
  test2l (1.0l, 2.0l);
122
 
123
  return 0;
124
}
125
 

powered by: WebSVN 2.1.0

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