| 1 |
/* 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 |
|
| 11 |
#include "builtins-config.h" |
| 12 |
|
| 13 |
extern double cos (double); |
| 14 |
extern double sin (double); |
| 15 |
extern double tan (double); |
| 16 |
extern double fabs (double); |
| 17 |
extern double atan2 (double, double); |
| 18 |
extern double copysign (double, double); |
| 19 |
extern double fmin (double, double); |
| 20 |
extern double fmax (double, double); |
| 21 |
extern double hypot (double, double); |
| 22 |
extern double pure (double) __attribute__ ((__pure__)); |
| 23 |
extern double carg (__complex__ double); |
| 24 |
extern __complex__ double ccos (__complex__ double); |
| 25 |
extern __complex__ double ctan (__complex__ double); |
| 26 |
extern float cosf (float); |
| 27 |
extern float sinf (float); |
| 28 |
extern float tanf (float); |
| 29 |
extern float fabsf (float); |
| 30 |
extern float atan2f (float, float); |
| 31 |
extern float copysignf (float, float); |
| 32 |
extern float fminf (float, float); |
| 33 |
extern float fmaxf (float, float); |
| 34 |
extern float hypotf (float, float); |
| 35 |
extern float puref (float) __attribute__ ((__pure__)); |
| 36 |
extern float cargf (__complex__ float); |
| 37 |
extern __complex__ float ccosf (__complex__ float); |
| 38 |
extern __complex__ float ctanf (__complex__ float); |
| 39 |
extern long double cosl (long double); |
| 40 |
extern long double sinl (long double); |
| 41 |
extern long double tanl (long double); |
| 42 |
extern long double fabsl (long double); |
| 43 |
extern long double atan2l (long double, long double); |
| 44 |
extern long double copysignl (long double, long double); |
| 45 |
extern long double fminl (long double, long double); |
| 46 |
extern long double fmaxl (long double, long double); |
| 47 |
extern long double hypotl (long double, long double); |
| 48 |
extern long double purel (long double) __attribute__ ((__pure__)); |
| 49 |
extern long double cargl (__complex__ long double); |
| 50 |
extern __complex__ long double ccosl (__complex__ long double); |
| 51 |
extern __complex__ long double ctanl (__complex__ long double); |
| 52 |
|
| 53 |
extern void link_error(void); |
| 54 |
|
| 55 |
void test1(double x) |
| 56 |
{ |
| 57 |
if (cos(x) != cos(-x)) |
| 58 |
link_error (); |
| 59 |
|
| 60 |
if (cos(x) != cos(fabs(x))) |
| 61 |
link_error (); |
| 62 |
|
| 63 |
if (cos(x) != cos(-fabs(x))) |
| 64 |
link_error (); |
| 65 |
|
| 66 |
if (cos(tan(x)) != cos(tan(-fabs(x)))) |
| 67 |
link_error (); |
| 68 |
|
| 69 |
if (sin(x)/cos(x) != tan(x)) |
| 70 |
link_error (); |
| 71 |
|
| 72 |
if (cos(x)/sin(x) != 1.0/tan(x)) |
| 73 |
link_error (); |
| 74 |
|
| 75 |
if (tan(x)*cos(x) != sin(x)) |
| 76 |
link_error (); |
| 77 |
|
| 78 |
if (cos(x)*tan(x) != sin(x)) |
| 79 |
link_error (); |
| 80 |
|
| 81 |
if (sin(x)/tan(x) != cos(x)) |
| 82 |
link_error (); |
| 83 |
|
| 84 |
if (tan(x)/sin(x) != 1.0/cos(x)) |
| 85 |
link_error (); |
| 86 |
} |
| 87 |
|
| 88 |
void test2(double x, double y) |
| 89 |
{ |
| 90 |
if (-tan(x-y) != tan(y-x)) |
| 91 |
link_error (); |
| 92 |
|
| 93 |
if (-sin(x-y) != sin(y-x)) |
| 94 |
link_error (); |
| 95 |
|
| 96 |
if (cos(-x*y) != cos(x*y)) |
| 97 |
link_error (); |
| 98 |
|
| 99 |
if (cos(x*-y) != cos(x*y)) |
| 100 |
link_error (); |
| 101 |
|
| 102 |
if (cos(-x/y) != cos(x/y)) |
| 103 |
link_error (); |
| 104 |
|
| 105 |
if (cos(x/-y) != cos(x/y)) |
| 106 |
link_error (); |
| 107 |
|
| 108 |
if (cos(-fabs(tan(x/-y))) != cos(tan(x/y))) |
| 109 |
link_error (); |
| 110 |
|
| 111 |
if (cos(y<10 ? -x : y) != cos(y<10 ? x : y)) |
| 112 |
link_error (); |
| 113 |
|
| 114 |
if (cos(y<10 ? x : -y) != cos(y<10 ? x : y)) |
| 115 |
link_error (); |
| 116 |
|
| 117 |
if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y))) |
| 118 |
!= cos(y<10 ? x : tan(x<20 ? x : y))) |
| 119 |
link_error (); |
| 120 |
|
| 121 |
if (cos((y*=3, -x)) != cos((y*=3,x))) |
| 122 |
link_error (); |
| 123 |
|
| 124 |
if (cos(-fabs(tan(x/-y))) != cos(tan(x/y))) |
| 125 |
link_error (); |
| 126 |
|
| 127 |
if (cos(copysign(x,y)) != cos(x)) |
| 128 |
link_error (); |
| 129 |
|
| 130 |
if (cos(copysign(-fabs(x),y*=2)) != cos((y*=2,x))) |
| 131 |
link_error (); |
| 132 |
|
| 133 |
if (hypot (x, 0) != fabs(x)) |
| 134 |
link_error (); |
| 135 |
|
| 136 |
if (hypot (0, x) != fabs(x)) |
| 137 |
link_error (); |
| 138 |
|
| 139 |
if (hypot (x, x) != fabs(x) * __builtin_sqrt(2)) |
| 140 |
link_error (); |
| 141 |
|
| 142 |
if (hypot (-x, y) != hypot (x, y)) |
| 143 |
link_error (); |
| 144 |
|
| 145 |
if (hypot (x, -y) != hypot (x, y)) |
| 146 |
link_error (); |
| 147 |
|
| 148 |
if (hypot (-x, -y) != hypot (x, y)) |
| 149 |
link_error (); |
| 150 |
|
| 151 |
if (hypot (fabs(x), y) != hypot (x, y)) |
| 152 |
link_error (); |
| 153 |
|
| 154 |
if (hypot (x, fabs(y)) != hypot (x, y)) |
| 155 |
link_error (); |
| 156 |
|
| 157 |
if (hypot (fabs(x), fabs(y)) != hypot (x, y)) |
| 158 |
link_error (); |
| 159 |
|
| 160 |
if (hypot (-fabs(-x), -fabs(fabs(fabs(-y)))) != hypot (x, y)) |
| 161 |
link_error (); |
| 162 |
|
| 163 |
if (hypot (-x, 0) != fabs(x)) |
| 164 |
link_error (); |
| 165 |
|
| 166 |
if (hypot (-x, x) != fabs(x) * __builtin_sqrt(2)) |
| 167 |
link_error (); |
| 168 |
|
| 169 |
if (hypot (pure(x), -pure(x)) != fabs(pure(x)) * __builtin_sqrt(2)) |
| 170 |
link_error (); |
| 171 |
|
| 172 |
if (hypot (tan(-x), tan(-fabs(y))) != hypot (tan(x), tan(y))) |
| 173 |
link_error (); |
| 174 |
|
| 175 |
if (fmin (fmax(x,y),y) != y) |
| 176 |
link_error (); |
| 177 |
|
| 178 |
if (fmin (fmax(y,x),y) != y) |
| 179 |
link_error (); |
| 180 |
|
| 181 |
if (fmin (x,fmax(x,y)) != x) |
| 182 |
link_error (); |
| 183 |
|
| 184 |
if (fmin (x,fmax(y,x)) != x) |
| 185 |
link_error (); |
| 186 |
|
| 187 |
if (fmax (fmin(x,y),y) != y) |
| 188 |
link_error (); |
| 189 |
|
| 190 |
if (fmax (fmin(y,x),y) != y) |
| 191 |
link_error (); |
| 192 |
|
| 193 |
if (fmax (x,fmin(x,y)) != x) |
| 194 |
link_error (); |
| 195 |
|
| 196 |
if (fmax (x,fmin(y,x)) != x) |
| 197 |
link_error (); |
| 198 |
|
| 199 |
if ((__complex__ double) x != -(__complex__ double) (-x)) |
| 200 |
link_error (); |
| 201 |
|
| 202 |
if (x*1i != -(-x*1i)) |
| 203 |
link_error (); |
| 204 |
|
| 205 |
if (x+(x-y)*1i != -(-x+(y-x)*1i)) |
| 206 |
link_error (); |
| 207 |
|
| 208 |
if (x+(x-y)*1i != -(-x-(x-y)*1i)) |
| 209 |
link_error (); |
| 210 |
|
| 211 |
if (ccos(tan(x)+sin(y)*1i) != ccos(-tan(-x)+-sin(-y)*1i)) |
| 212 |
link_error (); |
| 213 |
|
| 214 |
if (ccos(tan(x)+sin(x-y)*1i) != ccos(-tan(-x)-sin(y-x)*1i)) |
| 215 |
link_error (); |
| 216 |
|
| 217 |
if (-5+x*1i != -~(5+x*1i)) |
| 218 |
link_error (); |
| 219 |
|
| 220 |
if (tan(x)+tan(y)*1i != -~(tan(-x)+tan(y)*1i)) |
| 221 |
link_error (); |
| 222 |
} |
| 223 |
|
| 224 |
void test3(__complex__ double x, __complex__ double y, int i) |
| 225 |
{ |
| 226 |
if (carg(x) != atan2(__imag__ x, __real__ x)) |
| 227 |
link_error (); |
| 228 |
|
| 229 |
if (ccos(x) != ccos(-x)) |
| 230 |
link_error(); |
| 231 |
|
| 232 |
if (ccos(ctan(x)) != ccos(ctan(-x))) |
| 233 |
link_error(); |
| 234 |
|
| 235 |
if (ctan(x-y) != -ctan(y-x)) |
| 236 |
link_error(); |
| 237 |
|
| 238 |
if (ccos(x/y) != ccos(-x/y)) |
| 239 |
link_error(); |
| 240 |
|
| 241 |
if (ccos(x/y) != ccos(x/-y)) |
| 242 |
link_error(); |
| 243 |
|
| 244 |
if (ccos(x/ctan(y)) != ccos(-x/ctan(-y))) |
| 245 |
link_error(); |
| 246 |
|
| 247 |
if (ccos(x*y) != ccos(-x*y)) |
| 248 |
link_error(); |
| 249 |
|
| 250 |
if (ccos(x*y) != ccos(x*-y)) |
| 251 |
link_error(); |
| 252 |
|
| 253 |
if (ccos(ctan(x)*y) != ccos(ctan(-x)*-y)) |
| 254 |
link_error(); |
| 255 |
|
| 256 |
if (ccos(ctan(x/y)) != ccos(-ctan(x/-y))) |
| 257 |
link_error(); |
| 258 |
|
| 259 |
if (ccos(i ? x : y) != ccos(i ? -x : y)) |
| 260 |
link_error(); |
| 261 |
|
| 262 |
if (ccos(i ? x : y) != ccos(i ? x : -y)) |
| 263 |
link_error(); |
| 264 |
|
| 265 |
if (ccos(i ? x : ctan(y/x)) != ccos(i ? -x : -ctan(-y/x))) |
| 266 |
link_error(); |
| 267 |
|
| 268 |
if (~x != -~-x) |
| 269 |
link_error(); |
| 270 |
|
| 271 |
if (ccos(~x) != ccos(-~-x)) |
| 272 |
link_error(); |
| 273 |
|
| 274 |
if (ctan(~(x-y)) != -ctan(~(y-x))) |
| 275 |
link_error(); |
| 276 |
|
| 277 |
if (ctan(~(x/y)) != -ctan(~(x/-y))) |
| 278 |
link_error(); |
| 279 |
} |
| 280 |
|
| 281 |
void test1f(float x) |
| 282 |
{ |
| 283 |
if (cosf(x) != cosf(-x)) |
| 284 |
link_error (); |
| 285 |
|
| 286 |
if (cosf(x) != cosf(fabsf(x))) |
| 287 |
link_error (); |
| 288 |
|
| 289 |
if (cosf(x) != cosf(-fabsf(x))) |
| 290 |
link_error (); |
| 291 |
|
| 292 |
if (cosf(tanf(x)) != cosf(tanf(-fabsf(x)))) |
| 293 |
link_error (); |
| 294 |
|
| 295 |
#ifdef HAVE_C99_RUNTIME |
| 296 |
if (sinf(x)/cosf(x) != tanf(x)) |
| 297 |
link_error (); |
| 298 |
|
| 299 |
if (cosf(x)/sinf(x) != 1.0f/tanf(x)) |
| 300 |
link_error (); |
| 301 |
|
| 302 |
if (tanf(x)*cosf(x) != sinf(x)) |
| 303 |
link_error (); |
| 304 |
|
| 305 |
if (cosf(x)*tanf(x) != sinf(x)) |
| 306 |
link_error (); |
| 307 |
|
| 308 |
if (sinf(x)/tanf(x) != cosf(x)) |
| 309 |
link_error (); |
| 310 |
|
| 311 |
if (tanf(x)/sinf(x) != 1.0f/cosf(x)) |
| 312 |
link_error (); |
| 313 |
#endif |
| 314 |
} |
| 315 |
|
| 316 |
void test2f(float x, float y) |
| 317 |
{ |
| 318 |
if (-tanf(x-y) != tanf(y-x)) |
| 319 |
link_error (); |
| 320 |
|
| 321 |
if (-sinf(x-y) != sinf(y-x)) |
| 322 |
link_error (); |
| 323 |
|
| 324 |
if (cosf(-x*y) != cosf(x*y)) |
| 325 |
link_error (); |
| 326 |
|
| 327 |
if (cosf(x*-y) != cosf(x*y)) |
| 328 |
link_error (); |
| 329 |
|
| 330 |
if (cosf(-x/y) != cosf(x/y)) |
| 331 |
link_error (); |
| 332 |
|
| 333 |
if (cosf(x/-y) != cosf(x/y)) |
| 334 |
link_error (); |
| 335 |
|
| 336 |
if (cosf(-fabsf(tanf(x/-y))) != cosf(tanf(x/y))) |
| 337 |
link_error (); |
| 338 |
|
| 339 |
if (cosf(y<10 ? -x : y) != cosf(y<10 ? x : y)) |
| 340 |
link_error (); |
| 341 |
|
| 342 |
if (cosf(y<10 ? x : -y) != cosf(y<10 ? x : y)) |
| 343 |
link_error (); |
| 344 |
|
| 345 |
if (cosf(y<10 ? -fabsf(x) : tanf(x<20 ? -x : -fabsf(y))) |
| 346 |
!= cosf(y<10 ? x : tanf(x<20 ? x : y))) |
| 347 |
link_error (); |
| 348 |
|
| 349 |
if (cosf((y*=3, -x)) != cosf((y*=3,x))) |
| 350 |
link_error (); |
| 351 |
|
| 352 |
if (cosf(-fabsf(tanf(x/-y))) != cosf(tanf(x/y))) |
| 353 |
link_error (); |
| 354 |
|
| 355 |
if (cosf(copysignf(x,y)) != cosf(x)) |
| 356 |
link_error (); |
| 357 |
|
| 358 |
if (cosf(copysignf(-fabsf(x),y*=2)) != cosf((y*=2,x))) |
| 359 |
link_error (); |
| 360 |
|
| 361 |
if (hypotf (x, 0) != fabsf(x)) |
| 362 |
link_error (); |
| 363 |
|
| 364 |
if (hypotf (0, x) != fabsf(x)) |
| 365 |
link_error (); |
| 366 |
|
| 367 |
if (hypotf (x, x) != fabsf(x) * __builtin_sqrtf(2)) |
| 368 |
link_error (); |
| 369 |
|
| 370 |
if (hypotf (-x, y) != hypotf (x, y)) |
| 371 |
link_error (); |
| 372 |
|
| 373 |
if (hypotf (x, -y) != hypotf (x, y)) |
| 374 |
link_error (); |
| 375 |
|
| 376 |
if (hypotf (-x, -y) != hypotf (x, y)) |
| 377 |
link_error (); |
| 378 |
|
| 379 |
if (hypotf (fabsf(x), y) != hypotf (x, y)) |
| 380 |
link_error (); |
| 381 |
|
| 382 |
if (hypotf (x, fabsf(y)) != hypotf (x, y)) |
| 383 |
link_error (); |
| 384 |
|
| 385 |
if (hypotf (fabsf(x), fabsf(y)) != hypotf (x, y)) |
| 386 |
link_error (); |
| 387 |
|
| 388 |
if (hypotf (-fabsf(-x), -fabsf(fabsf(fabsf(-y)))) != hypotf (x, y)) |
| 389 |
link_error (); |
| 390 |
|
| 391 |
if (hypotf (-x, 0) != fabsf(x)) |
| 392 |
link_error (); |
| 393 |
|
| 394 |
if (hypotf (-x, x) != fabsf(x) * __builtin_sqrtf(2)) |
| 395 |
link_error (); |
| 396 |
|
| 397 |
if (hypotf (puref(x), -puref(x)) != fabsf(puref(x)) * __builtin_sqrtf(2)) |
| 398 |
link_error (); |
| 399 |
|
| 400 |
if (hypotf (tanf(-x), tanf(-fabsf(y))) != hypotf (tanf(x), tanf(y))) |
| 401 |
link_error (); |
| 402 |
|
| 403 |
if (fminf (fmaxf(x,y),y) != y) |
| 404 |
link_error (); |
| 405 |
|
| 406 |
if (fminf (fmaxf(y,x),y) != y) |
| 407 |
link_error (); |
| 408 |
|
| 409 |
if (fminf (x,fmaxf(x,y)) != x) |
| 410 |
link_error (); |
| 411 |
|
| 412 |
if (fminf (x,fmaxf(y,x)) != x) |
| 413 |
link_error (); |
| 414 |
|
| 415 |
if (fmaxf (fminf(x,y),y) != y) |
| 416 |
link_error (); |
| 417 |
|
| 418 |
if (fmaxf (fminf(y,x),y) != y) |
| 419 |
link_error (); |
| 420 |
|
| 421 |
if (fmaxf (x,fminf(x,y)) != x) |
| 422 |
link_error (); |
| 423 |
|
| 424 |
if (fmaxf (x,fminf(y,x)) != x) |
| 425 |
link_error (); |
| 426 |
|
| 427 |
if ((__complex__ float) x != -(__complex__ float) (-x)) |
| 428 |
link_error (); |
| 429 |
|
| 430 |
if (x+(x-y)*1i != -(-x+(y-x)*1i)) |
| 431 |
link_error (); |
| 432 |
|
| 433 |
if (x+(x-y)*1i != -(-x-(x-y)*1i)) |
| 434 |
link_error (); |
| 435 |
|
| 436 |
if (ccosf(tanf(x)+sinf(y)*1i) != ccosf(-tanf(-x)+-sinf(-y)*1i)) |
| 437 |
link_error (); |
| 438 |
|
| 439 |
if (ccosf(tanf(x)+sinf(x-y)*1i) != ccosf(-tanf(-x)-sinf(y-x)*1i)) |
| 440 |
link_error (); |
| 441 |
|
| 442 |
if (-5+x*1i != -~(5+x*1i)) |
| 443 |
link_error (); |
| 444 |
|
| 445 |
if (tanf(x)+tanf(y)*1i != -~(tanf(-x)+tanf(y)*1i)) |
| 446 |
link_error (); |
| 447 |
} |
| 448 |
|
| 449 |
void test3f(__complex__ float x, __complex__ float y, int i) |
| 450 |
{ |
| 451 |
if (ccosf(x) != ccosf(-x)) |
| 452 |
link_error(); |
| 453 |
|
| 454 |
if (ccosf(ctanf(x)) != ccosf(ctanf(-x))) |
| 455 |
link_error(); |
| 456 |
|
| 457 |
if (ctanf(x-y) != -ctanf(y-x)) |
| 458 |
link_error(); |
| 459 |
|
| 460 |
if (ccosf(x/y) != ccosf(-x/y)) |
| 461 |
link_error(); |
| 462 |
|
| 463 |
if (ccosf(x/y) != ccosf(x/-y)) |
| 464 |
link_error(); |
| 465 |
|
| 466 |
if (ccosf(x/ctanf(y)) != ccosf(-x/ctanf(-y))) |
| 467 |
link_error(); |
| 468 |
|
| 469 |
if (ccosf(x*y) != ccosf(-x*y)) |
| 470 |
link_error(); |
| 471 |
|
| 472 |
if (ccosf(x*y) != ccosf(x*-y)) |
| 473 |
link_error(); |
| 474 |
|
| 475 |
if (ccosf(ctanf(x)*y) != ccosf(ctanf(-x)*-y)) |
| 476 |
link_error(); |
| 477 |
|
| 478 |
if (ccosf(ctanf(x/y)) != ccosf(-ctanf(x/-y))) |
| 479 |
link_error(); |
| 480 |
|
| 481 |
if (ccosf(i ? x : y) != ccosf(i ? -x : y)) |
| 482 |
link_error(); |
| 483 |
|
| 484 |
if (ccosf(i ? x : y) != ccosf(i ? x : -y)) |
| 485 |
link_error(); |
| 486 |
|
| 487 |
if (ccosf(i ? x : ctanf(y/x)) != ccosf(i ? -x : -ctanf(-y/x))) |
| 488 |
link_error(); |
| 489 |
|
| 490 |
if (~x != -~-x) |
| 491 |
link_error(); |
| 492 |
|
| 493 |
if (ccosf(~x) != ccosf(-~-x)) |
| 494 |
link_error(); |
| 495 |
|
| 496 |
if (ctanf(~(x-y)) != -ctanf(~(y-x))) |
| 497 |
link_error(); |
| 498 |
|
| 499 |
if (ctanf(~(x/y)) != -ctanf(~(x/-y))) |
| 500 |
link_error(); |
| 501 |
|
| 502 |
#ifdef HAVE_C99_RUNTIME |
| 503 |
if (cargf(x) != atan2f(__imag__ x, __real__ x)) |
| 504 |
link_error (); |
| 505 |
#endif |
| 506 |
} |
| 507 |
|
| 508 |
void test1l(long double x) |
| 509 |
{ |
| 510 |
if (cosl(x) != cosl(-x)) |
| 511 |
link_error (); |
| 512 |
|
| 513 |
if (cosl(x) != cosl(fabsl(x))) |
| 514 |
link_error (); |
| 515 |
|
| 516 |
if (cosl(x) != cosl(-fabsl(x))) |
| 517 |
link_error (); |
| 518 |
|
| 519 |
if (cosl(tanl(x)) != cosl(tanl(-fabsl(x)))) |
| 520 |
link_error (); |
| 521 |
|
| 522 |
#ifdef HAVE_C99_RUNTIME |
| 523 |
if (sinl(x)/cosl(x) != tanl(x)) |
| 524 |
link_error (); |
| 525 |
|
| 526 |
if (cosl(x)/sinl(x) != 1.0l/tanl(x)) |
| 527 |
link_error (); |
| 528 |
|
| 529 |
if (tanl(x)*cosl(x) != sinl(x)) |
| 530 |
link_error (); |
| 531 |
|
| 532 |
if (cosl(x)*tanl(x) != sinl(x)) |
| 533 |
link_error (); |
| 534 |
|
| 535 |
if (sinl(x)/tanl(x) != cosl(x)) |
| 536 |
link_error (); |
| 537 |
|
| 538 |
if (tanl(x)/sinl(x) != 1.0l/cosl(x)) |
| 539 |
link_error (); |
| 540 |
#endif |
| 541 |
} |
| 542 |
|
| 543 |
void test2l(long double x, long double y) |
| 544 |
{ |
| 545 |
if (-tanl(x-y) != tanl(y-x)) |
| 546 |
link_error (); |
| 547 |
|
| 548 |
if (-sinl(x-y) != sinl(y-x)) |
| 549 |
link_error (); |
| 550 |
|
| 551 |
if (cosl(-x*y) != cosl(x*y)) |
| 552 |
link_error (); |
| 553 |
|
| 554 |
if (cosl(x*-y) != cosl(x*y)) |
| 555 |
link_error (); |
| 556 |
|
| 557 |
if (cosl(-x/y) != cosl(x/y)) |
| 558 |
link_error (); |
| 559 |
|
| 560 |
if (cosl(x/-y) != cosl(x/y)) |
| 561 |
link_error (); |
| 562 |
|
| 563 |
if (cosl(-fabsl(tanl(x/-y))) != cosl(tanl(x/y))) |
| 564 |
link_error (); |
| 565 |
|
| 566 |
if (cosl(y<10 ? -x : y) != cosl(y<10 ? x : y)) |
| 567 |
link_error (); |
| 568 |
|
| 569 |
if (cosl(y<10 ? x : -y) != cosl(y<10 ? x : y)) |
| 570 |
link_error (); |
| 571 |
|
| 572 |
if (cosl(y<10 ? -fabsl(x) : tanl(x<20 ? -x : -fabsl(y))) |
| 573 |
!= cosl(y<10 ? x : tanl(x<20 ? x : y))) |
| 574 |
link_error (); |
| 575 |
|
| 576 |
if (cosl((y*=3, -x)) != cosl((y*=3,x))) |
| 577 |
link_error (); |
| 578 |
|
| 579 |
if (cosl(-fabsl(tanl(x/-y))) != cosl(tanl(x/y))) |
| 580 |
link_error (); |
| 581 |
|
| 582 |
if (cosl(copysignl(x,y)) != cosl(x)) |
| 583 |
link_error (); |
| 584 |
|
| 585 |
if (cosl(copysignl(-fabsl(x),y*=2)) != cosl((y*=2,x))) |
| 586 |
link_error (); |
| 587 |
|
| 588 |
if (hypotl (x, 0) != fabsl(x)) |
| 589 |
link_error (); |
| 590 |
|
| 591 |
if (hypotl (0, x) != fabsl(x)) |
| 592 |
link_error (); |
| 593 |
|
| 594 |
if (hypotl (x, x) != fabsl(x) * __builtin_sqrtl(2)) |
| 595 |
link_error (); |
| 596 |
|
| 597 |
if (hypotl (-x, y) != hypotl (x, y)) |
| 598 |
link_error (); |
| 599 |
|
| 600 |
if (hypotl (x, -y) != hypotl (x, y)) |
| 601 |
link_error (); |
| 602 |
|
| 603 |
if (hypotl (-x, -y) != hypotl (x, y)) |
| 604 |
link_error (); |
| 605 |
|
| 606 |
if (hypotl (fabsl(x), y) != hypotl (x, y)) |
| 607 |
link_error (); |
| 608 |
|
| 609 |
if (hypotl (x, fabsl(y)) != hypotl (x, y)) |
| 610 |
link_error (); |
| 611 |
|
| 612 |
if (hypotl (fabsl(x), fabsl(y)) != hypotl (x, y)) |
| 613 |
link_error (); |
| 614 |
|
| 615 |
if (hypotl (-fabsl(-x), -fabsl(fabsl(fabsl(-y)))) != hypotl (x, y)) |
| 616 |
link_error (); |
| 617 |
|
| 618 |
if (hypotl (-x, 0) != fabsl(x)) |
| 619 |
link_error (); |
| 620 |
|
| 621 |
if (hypotl (-x, x) != fabsl(x) * __builtin_sqrtl(2)) |
| 622 |
link_error (); |
| 623 |
|
| 624 |
if (hypotl (purel(x), -purel(x)) != fabsl(purel(x)) * __builtin_sqrtl(2)) |
| 625 |
link_error (); |
| 626 |
|
| 627 |
if (hypotl (tanl(-x), tanl(-fabsl(y))) != hypotl (tanl(x), tanl(y))) |
| 628 |
link_error (); |
| 629 |
|
| 630 |
if (fminl (fmaxl(x,y),y) != y) |
| 631 |
link_error (); |
| 632 |
|
| 633 |
if (fminl (fmaxl(y,x),y) != y) |
| 634 |
link_error (); |
| 635 |
|
| 636 |
if (fminl (x,fmaxl(x,y)) != x) |
| 637 |
link_error (); |
| 638 |
|
| 639 |
if (fminl (x,fmaxl(y,x)) != x) |
| 640 |
link_error (); |
| 641 |
|
| 642 |
if (fmaxl (fminl(x,y),y) != y) |
| 643 |
link_error (); |
| 644 |
|
| 645 |
if (fmaxl (fminl(y,x),y) != y) |
| 646 |
link_error (); |
| 647 |
|
| 648 |
if (fmaxl (x,fminl(x,y)) != x) |
| 649 |
link_error (); |
| 650 |
|
| 651 |
if (fmaxl (x,fminl(y,x)) != x) |
| 652 |
link_error (); |
| 653 |
|
| 654 |
if ((__complex__ long double) x != -(__complex__ long double) (-x)) |
| 655 |
link_error (); |
| 656 |
|
| 657 |
if (x+(x-y)*1i != -(-x+(y-x)*1i)) |
| 658 |
link_error (); |
| 659 |
|
| 660 |
if (x+(x-y)*1i != -(-x-(x-y)*1i)) |
| 661 |
link_error (); |
| 662 |
|
| 663 |
if (ccosl(tanl(x)+sinl(y)*1i) != ccosl(-tanl(-x)+-sinl(-y)*1i)) |
| 664 |
link_error (); |
| 665 |
|
| 666 |
if (ccosl(tanl(x)+sinl(x-y)*1i) != ccosl(-tanl(-x)-sinl(y-x)*1i)) |
| 667 |
link_error (); |
| 668 |
|
| 669 |
if (-5+x*1i != -~(5+x*1i)) |
| 670 |
link_error (); |
| 671 |
|
| 672 |
if (tanl(x)+tanl(y)*1i != -~(tanl(-x)+tanl(y)*1i)) |
| 673 |
link_error (); |
| 674 |
} |
| 675 |
|
| 676 |
void test3l(__complex__ long double x, __complex__ long double y, int i) |
| 677 |
{ |
| 678 |
if (ccosl(x) != ccosl(-x)) |
| 679 |
link_error(); |
| 680 |
|
| 681 |
if (ccosl(ctanl(x)) != ccosl(ctanl(-x))) |
| 682 |
link_error(); |
| 683 |
|
| 684 |
if (ctanl(x-y) != -ctanl(y-x)) |
| 685 |
link_error(); |
| 686 |
|
| 687 |
if (ccosl(x/y) != ccosl(-x/y)) |
| 688 |
link_error(); |
| 689 |
|
| 690 |
if (ccosl(x/y) != ccosl(x/-y)) |
| 691 |
link_error(); |
| 692 |
|
| 693 |
if (ccosl(x/ctanl(y)) != ccosl(-x/ctanl(-y))) |
| 694 |
link_error(); |
| 695 |
|
| 696 |
if (ccosl(x*y) != ccosl(-x*y)) |
| 697 |
link_error(); |
| 698 |
|
| 699 |
if (ccosl(x*y) != ccosl(x*-y)) |
| 700 |
link_error(); |
| 701 |
|
| 702 |
if (ccosl(ctanl(x)*y) != ccosl(ctanl(-x)*-y)) |
| 703 |
link_error(); |
| 704 |
|
| 705 |
if (ccosl(ctanl(x/y)) != ccosl(-ctanl(x/-y))) |
| 706 |
link_error(); |
| 707 |
|
| 708 |
if (ccosl(i ? x : y) != ccosl(i ? -x : y)) |
| 709 |
link_error(); |
| 710 |
|
| 711 |
if (ccosl(i ? x : y) != ccosl(i ? x : -y)) |
| 712 |
link_error(); |
| 713 |
|
| 714 |
if (ccosl(i ? x : ctanl(y/x)) != ccosl(i ? -x : -ctanl(-y/x))) |
| 715 |
link_error(); |
| 716 |
|
| 717 |
if (~x != -~-x) |
| 718 |
link_error(); |
| 719 |
|
| 720 |
if (ccosl(~x) != ccosl(-~-x)) |
| 721 |
link_error(); |
| 722 |
|
| 723 |
if (ctanl(~(x-y)) != -ctanl(~(y-x))) |
| 724 |
link_error(); |
| 725 |
|
| 726 |
if (ctanl(~(x/y)) != -ctanl(~(x/-y))) |
| 727 |
link_error(); |
| 728 |
|
| 729 |
#ifdef HAVE_C99_RUNTIME |
| 730 |
if (cargl(x) != atan2l(__imag__ x, __real__ x)) |
| 731 |
link_error (); |
| 732 |
#endif |
| 733 |
} |
| 734 |
|
| 735 |
int main() |
| 736 |
{ |
| 737 |
test1 (1.0); |
| 738 |
test2 (1.0, 2.0); |
| 739 |
|
| 740 |
test1f (1.0f); |
| 741 |
test2f (1.0f, 2.0f); |
| 742 |
|
| 743 |
test1l (1.0l); |
| 744 |
test2l (1.0l, 2.0l); |
| 745 |
|
| 746 |
return 0; |
| 747 |
} |
| 748 |
|