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-50.c] - Blame information for rev 298

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 copysign(double,double);
5
extern float copysignf(float,float);
6
extern double fabs(double);
7
extern float fabsf(float);
8
extern void abort(void);
9
 
10
 
11
double test1(double x, double y)
12
{
13
  return copysign(-x,y);
14
}
15
 
16
float test1f(float x, float y)
17
{
18
  return copysignf(-x,y);
19
}
20
 
21
double test2(double x, double y)
22
{
23
  return copysign(fabs(x),y);
24
}
25
 
26
float test2f(float x, float y)
27
{
28
  return copysignf(fabsf(x),y);
29
}
30
 
31
double test3(double x, double y, double z)
32
{
33
  return copysign(x*-y,z);
34
}
35
 
36
float test3f(float x, float y, float z)
37
{
38
  return copysignf(x*-y,z);
39
}
40
 
41
double test4(double x, double y, double z)
42
{
43
  return copysign(x/-y,z);
44
}
45
 
46
float test4f(float x, float y, float z)
47
{
48
  return copysignf(x/-y,z);
49
}
50
 
51
int main()
52
{
53
  if (test1(3.0,2.0) != 3.0)
54
    abort();
55
  if (test1(3.0,-2.0) != -3.0)
56
    abort();
57
  if (test1(-3.0,2.0) != 3.0)
58
    abort();
59
  if (test1(-3.0,-2.0) != -3.0)
60
    abort();
61
 
62
  if (test1f(3.0f,2.0f) != 3.0f)
63
    abort();
64
  if (test1f(3.0f,-2.0f) != -3.0f)
65
    abort();
66
  if (test1f(-3.0f,2.0f) != 3.0f)
67
    abort();
68
  if (test1f(-3.0f,-2.0f) != -3.0f)
69
    abort();
70
 
71
  if (test2(3.0,2.0) != 3.0)
72
    abort();
73
  if (test2(3.0,-2.0) != -3.0)
74
    abort();
75
  if (test2(-3.0,2.0) != 3.0)
76
    abort();
77
  if (test2(-3.0,-2.0) != -3.0)
78
    abort();
79
 
80
  if (test2f(3.0f,2.0f) != 3.0f)
81
    abort();
82
  if (test2f(3.0f,-2.0f) != -3.0f)
83
    abort();
84
  if (test2f(-3.0f,2.0f) != 3.0f)
85
    abort();
86
  if (test2f(-3.0f,-2.0f) != -3.0f)
87
    abort();
88
 
89
  if (test3(2.0,3.0,4.0) != 6.0)
90
    abort();
91
  if (test3(2.0,3.0,-4.0) != -6.0)
92
    abort();
93
  if (test3(2.0,-3.0,4.0) != 6.0)
94
    abort();
95
  if (test3(2.0,-3.0,-4.0) != -6.0)
96
    abort();
97
  if (test3(-2.0,3.0,4.0) != 6.0)
98
    abort();
99
  if (test3(-2.0,3.0,-4.0) != -6.0)
100
    abort();
101
  if (test3(-2.0,-3.0,4.0) != 6.0)
102
    abort();
103
  if (test3(-2.0,-3.0,-4.0) != -6.0)
104
    abort();
105
 
106
  if (test3f(2.0f,3.0f,4.0f) != 6.0f)
107
    abort();
108
  if (test3f(2.0f,3.0f,-4.0f) != -6.0f)
109
    abort();
110
  if (test3f(2.0f,-3.0f,4.0f) != 6.0f)
111
    abort();
112
  if (test3f(2.0f,-3.0f,-4.0f) != -6.0f)
113
    abort();
114
  if (test3f(-2.0f,3.0f,4.0f) != 6.0f)
115
    abort();
116
  if (test3f(-2.0f,3.0f,-4.0f) != -6.0f)
117
    abort();
118
  if (test3f(-2.0f,-3.0f,4.0f) != 6.0f)
119
    abort();
120
  if (test3f(-2.0f,-3.0f,-4.0f) != -6.0f)
121
    abort();
122
 
123
  if (test4(8.0,2.0,3.0) != 4.0)
124
    abort();
125
  if (test4(8.0,2.0,-3.0) != -4.0)
126
    abort();
127
  if (test4(8.0,-2.0,3.0) != 4.0)
128
    abort();
129
  if (test4(8.0,-2.0,-3.0) != -4.0)
130
    abort();
131
  if (test4(-8.0,2.0,3.0) != 4.0)
132
    abort();
133
  if (test4(-8.0,2.0,-3.0) != -4.0)
134
    abort();
135
  if (test4(-8.0,-2.0,3.0) != 4.0)
136
    abort();
137
  if (test4(-8.0,-2.0,-3.0) != -4.0)
138
    abort();
139
 
140
  if (test4f(8.0f,2.0f,3.0f) != 4.0f)
141
    abort();
142
  if (test4f(8.0f,2.0f,-3.0f) != -4.0f)
143
    abort();
144
  if (test4f(8.0f,-2.0f,3.0f) != 4.0f)
145
    abort();
146
  if (test4f(8.0f,-2.0f,-3.0f) != -4.0f)
147
    abort();
148
  if (test4f(-8.0f,2.0f,3.0f) != 4.0f)
149
    abort();
150
  if (test4f(-8.0f,2.0f,-3.0f) != -4.0f)
151
    abort();
152
  if (test4f(-8.0f,-2.0f,3.0f) != 4.0f)
153
    abort();
154
  if (test4f(-8.0f,-2.0f,-3.0f) != -4.0f)
155
    abort();
156
 
157
  return 0;
158
}
159
 

powered by: WebSVN 2.1.0

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