[AArch64/arm] PR testsuite/85326 Avoid C++ tests when C++ compiler not present
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / copysign_1.c
blob27fb9ca4ed7a7abcc21549dea32c24d2ffdca3f4
1 /* { dg-do run } */
2 /* { dg-options "-O2 --save-temps" } */
4 double fabs (double);
6 double
7 check (double x, double y)
9 return __builtin_copysign (x, y);
12 double
13 check1 (double x)
15 return __builtin_copysign (x, 1.0);
18 double
19 check2 (double x)
21 return __builtin_copysign (1.0, x);
24 double
25 check3 (double x)
27 return -__builtin_copysign (x, 1.0);
30 double
31 check4 (double x, double y)
33 return x * __builtin_copysign (x, y);
36 double
37 check5 (double x, double y)
39 return __builtin_copysign (-x, -y);
42 int
43 main (int argc, char** argv)
45 double x = 2.0;
46 double y = -5.0;
47 double epsilon = 0.00001;
49 double expected = -2.0;
51 if (fabs (check (x, y) - expected) >= epsilon)
52 __builtin_abort ();
54 expected = 2.0;
56 if (fabs (check1 (x) - expected) >= epsilon)
57 __builtin_abort ();
59 expected = 1.0;
61 if (fabs (check2 (x) - expected) >= epsilon)
62 __builtin_abort ();
64 expected = -2.0;
66 if (fabs (check3 (x) - expected) >= epsilon)
67 __builtin_abort ();
69 expected = -4.0;
71 if (fabs (check4 (x, y) - expected) >= epsilon)
72 __builtin_abort ();
74 expected = 2.0;
76 if (fabs (check5 (x, y) - expected) >= epsilon)
77 __builtin_abort ();
80 /* { dg-final { scan-assembler-not "copysign\tw" } } */