OSDN Git Service

Merge basic-improvements-branch to trunk
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / builtins-2.c
1 /* Copyright (C) 2002  Free Software Foundation.
2
3    Verify that built-in math function constant folding doesn't
4    cause any problems for the compiler.
5
6    Written by Roger Sayle, 16th August 2002.  */
7
8 /* { dg-do compile } */
9 /* { dg-options "-O2 -ffast-math" } */
10
11 double test1(double x)
12 {
13   return log(exp(x));
14 }
15
16 double test2(double x)
17 {
18   return exp(log(x));
19 }
20
21 double test3(double x)
22 {
23   return sqrt(exp(x));
24 }
25
26 double test4(double x)
27 {
28   return log(sqrt(x));
29 }
30
31 double test5(double x, double y)
32 {
33   return sqrt(x)*sqrt(y);
34 }
35
36 double test6(double x, double y)
37 {
38   return exp(x)*exp(y);
39 }
40
41 double test7(double x, double y)
42 {
43   return x/exp(y);
44 }
45
46 double test8(double x)
47 {
48   return fabs(sqrt(x));
49 }
50
51 double test9(double x)
52 {
53   return fabs(exp(x));
54 }
55
56 float test1f(float x)
57 {
58   return logf(expf(x));
59 }
60
61 float test2f(float x)
62 {
63   return expf(logf(x));
64 }
65
66 float test3f(float x)
67 {
68   return sqrtf(expf(x));
69 }
70
71 float test4f(float x)
72 {
73   return logf(sqrtf(x));
74 }
75
76 float test5f(float x, float y)
77 {
78   return sqrtf(x)*sqrtf(y);
79 }
80
81 float test6f(float x, float y)
82 {
83   return expf(x)*expf(y);
84 }
85
86 float test7f(float x, float y)
87 {
88   return x/expf(y);
89 }
90
91 float test8f(float x)
92 {
93   return fabsf(sqrtf(x));
94 }
95
96 float test9f(float x)
97 {
98   return fabsf(expf(x));
99 }
100
101 long double test1l(long double x)
102 {
103   return logl(expl(x));
104 }
105
106 long double test2l(long double x)
107 {
108   return expl(logl(x));
109 }
110
111 long double test3l(long double x)
112 {
113   return sqrtl(expl(x));
114 }
115
116 long double test4l(long double x)
117 {
118   return logl(sqrtl(x));
119 }
120
121 long double test5l(long double x, long double y)
122 {
123   return sqrtl(x)*sqrtl(y);
124 }
125
126 long double test6l(long double x, long double y)
127 {
128   return expl(x)*expl(y);
129 }
130
131 long double test7l(long double x, long double y)
132 {
133   return x/expl(y);
134 }
135
136 long double test8l(long double x)
137 {
138   return fabsl(sqrtl(x));
139 }
140
141 long double test9l(long double x)
142 {
143   return fabsl(expl(x));
144 }
145
146