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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [builtins-48.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-O2" } */
3
 
4
extern double fabs(double);
5
extern float fabsf(float);
6
extern void abort(void);
7
 
8
 
9
double test1(double x)
10
{
11
  return (-x)*(-x);
12
}
13
 
14
float test1f(float x)
15
{
16
  return (-x)*(-x);
17
}
18
 
19
double test2(double x)
20
{
21
  return fabs(x)*fabs(x);
22
}
23
 
24
float test2f(float x)
25
{
26
  return fabsf(x)*fabsf(x);
27
}
28
 
29
double test3(double x, double y)
30
{
31
  return (x*-y)*(x*-y);
32
}
33
 
34
float test3f(float x, float y)
35
{
36
  return (x*-y)*(x*-y);
37
}
38
 
39
double test4(double x, double y)
40
{
41
  return (x/-y)*(x/-y);
42
}
43
 
44
float test4f(float x, float y)
45
{
46
  return (x/-y)*(x/-y);
47
}
48
 
49
int main()
50
{
51
  if (test1(1.0) != 1.0)
52
    abort();
53
  if (test1(2.0) != 4.0)
54
    abort();
55
  if (test1(0.0) != 0.0)
56
    abort();
57
  if (test1(-1.0) != 1.0)
58
    abort();
59
  if (test1(-2.0) != 4.0)
60
    abort();
61
 
62
  if (test1f(1.0f) != 1.0f)
63
    abort();
64
  if (test1f(2.0f) != 4.0f)
65
    abort();
66
  if (test1f(0.0f) != 0.0f)
67
    abort();
68
  if (test1f(-1.0f) != 1.0f)
69
    abort();
70
  if (test1f(-2.0f) != 4.0f)
71
    abort();
72
 
73
  if (test2(1.0) != 1.0)
74
    abort();
75
  if (test2(2.0) != 4.0)
76
    abort();
77
  if (test2(0.0) != 0.0)
78
    abort();
79
  if (test2(-1.0) != 1.0)
80
    abort();
81
  if (test2(-2.0) != 4.0)
82
    abort();
83
 
84
  if (test2f(1.0f) != 1.0f)
85
    abort();
86
  if (test2f(2.0f) != 4.0f)
87
    abort();
88
  if (test2f(0.0f) != 0.0f)
89
    abort();
90
  if (test2f(-1.0f) != 1.0f)
91
    abort();
92
  if (test2f(-2.0f) != 4.0f)
93
    abort();
94
 
95
  if (test3(1.0,1.0) != 1.0)
96
    abort();
97
  if (test3(1.0,-1.0) != 1.0)
98
    abort();
99
  if (test3(1.0,2.0) != 4.0)
100
    abort();
101
  if (test3(1.0,-2.0) != 4.0)
102
    abort();
103
  if (test3(2.0,1.0) != 4.0)
104
    abort();
105
  if (test3(2.0,-1.0) != 4.0)
106
    abort();
107
  if (test3(2.0,2.0) != 16.0)
108
    abort();
109
  if (test3(2.0,-2.0) != 16.0)
110
    abort();
111
  if (test3(-2.0,1.0) != 4.0)
112
    abort();
113
  if (test3(-2.0,-1.0) != 4.0)
114
    abort();
115
  if (test3(-2.0,2.0) != 16.0)
116
    abort();
117
  if (test3(-2.0,-2.0) != 16.0)
118
    abort();
119
 
120
  if (test3f(1.0f,1.0f) != 1.0f)
121
    abort();
122
  if (test3f(1.0f,-1.0f) != 1.0f)
123
    abort();
124
  if (test3f(1.0f,2.0f) != 4.0f)
125
    abort();
126
  if (test3f(1.0f,-2.0f) != 4.0f)
127
    abort();
128
  if (test3f(2.0f,1.0f) != 4.0f)
129
    abort();
130
  if (test3f(2.0f,-1.0f) != 4.0f)
131
    abort();
132
  if (test3f(2.0f,2.0f) != 16.0f)
133
    abort();
134
  if (test3f(2.0f,-2.0f) != 16.0f)
135
    abort();
136
  if (test3f(-2.0f,1.0f) != 4.0f)
137
    abort();
138
  if (test3f(-2.0f,-1.0f) != 4.0f)
139
    abort();
140
  if (test3f(-2.0f,2.0f) != 16.0f)
141
    abort();
142
  if (test3f(-2.0f,-2.0f) != 16.0f)
143
    abort();
144
 
145
  if (test4(1.0,1.0) != 1.0)
146
    abort();
147
  if (test4(1.0,-1.0) != 1.0)
148
    abort();
149
  if (test4(-1.0,1.0) != 1.0)
150
    abort();
151
  if (test4(-1.0,-1.0) != 1.0)
152
    abort();
153
  if (test4(6.0,3.0) != 4.0)
154
    abort();
155
  if (test4(6.0,-3.0) != 4.0)
156
    abort();
157
  if (test4(-6.0,3.0) != 4.0)
158
    abort();
159
  if (test4(-6.0,-3.0) != 4.0)
160
    abort();
161
 
162
  if (test4f(1.0f,1.0f) != 1.0f)
163
    abort();
164
  if (test4f(1.0f,-1.0f) != 1.0f)
165
    abort();
166
  if (test4f(-1.0f,1.0f) != 1.0f)
167
    abort();
168
  if (test4f(-1.0f,-1.0f) != 1.0f)
169
    abort();
170
  if (test4f(6.0f,3.0f) != 4.0f)
171
    abort();
172
  if (test4f(6.0f,-3.0f) != 4.0f)
173
    abort();
174
  if (test4f(-6.0f,3.0f) != 4.0f)
175
    abort();
176
  if (test4f(-6.0f,-3.0f) != 4.0f)
177
    abort();
178
 
179
  return 0;
180
}
181
 

powered by: WebSVN 2.1.0

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