PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / builtins-50.c
blob2d32d1ed960af63169766532cd9b5fc99a340f84
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
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);
11 double test1(double x, double y)
13 return copysign(-x,y);
16 float test1f(float x, float y)
18 return copysignf(-x,y);
21 double test2(double x, double y)
23 return copysign(fabs(x),y);
26 float test2f(float x, float y)
28 return copysignf(fabsf(x),y);
31 double test3(double x, double y, double z)
33 return copysign(x*-y,z);
36 float test3f(float x, float y, float z)
38 return copysignf(x*-y,z);
41 double test4(double x, double y, double z)
43 return copysign(x/-y,z);
46 float test4f(float x, float y, float z)
48 return copysignf(x/-y,z);
51 int main()
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();
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();
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();
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();
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();
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();
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();
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();
157 return 0;