Small ChangeLog tweak.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / builtin-symmetric-1.c
blob61d8a80d72aca94298a90b30149b0591280b650e
1 /* Copyright (C) 2006 Free Software Foundation.
3 Verify that built-in math function folding of symmetric even and
4 odd functions is correctly performed by the compiler.
6 Origin: Kaveh R. Ghazi, November 09, 2006. */
8 /* { dg-do link } */
9 /* { dg-options "-ffast-math" } */
10 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
12 /* All references to link_error should go away at compile-time. */
13 extern void link_error(int);
15 /* Test that FUNC(-ARG) == FUNC(ARG). */
16 #define TESTIT_EVEN(FUNC) do { \
17 if (__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \
18 link_error(__LINE__); \
19 if (__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \
20 link_error(__LINE__); \
21 if (__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \
22 link_error(__LINE__); \
23 } while (0)
25 /* Test that FUNC(-ARG) == FUNC(ARG), where ARG has a complex type. */
26 #define TESTIT_EVEN_C(FUNC) do { \
27 if (__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \
28 link_error(__LINE__); \
29 if (__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \
30 link_error(__LINE__); \
31 if (__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \
32 link_error(__LINE__); \
33 } while (0)
35 /* Test that FUNC(-VAR) == FUNC(VAR), where VAR has an int type. */
36 #define TESTIT_EVEN_I(FUNC,VAR) do { \
37 if (__builtin_##FUNC(-VAR) != __builtin_##FUNC(VAR)) \
38 link_error(__LINE__); \
39 } while (0)
41 /* Test that -FUNC(ARG) == FUNC(-ARG). */
42 #define TESTIT_ODD(FUNC) do { \
43 if (-__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \
44 link_error(__LINE__); \
45 if (-__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \
46 link_error(__LINE__); \
47 if (-__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \
48 link_error(__LINE__); \
49 } while (0)
51 /* Test that -FUNC(ARG) == FUNC(-ARG), where ARG has a complex type. */
52 #define TESTIT_ODD_C(FUNC) do { \
53 if (-__builtin_##FUNC##f(-cxf) != __builtin_##FUNC##f(cxf)) \
54 link_error(__LINE__); \
55 if (-__builtin_##FUNC(-cx) != __builtin_##FUNC(cx)) \
56 link_error(__LINE__); \
57 if (-__builtin_##FUNC##l(-cxl) != __builtin_##FUNC##l(cxl)) \
58 link_error(__LINE__); \
59 } while (0)
61 void foo (float xf, double x, long double xl,
62 __complex__ float cxf, __complex__ double cx, __complex__ long double cxl,
63 int i, long l, long long ll, __INTMAX_TYPE__ im)
65 TESTIT_EVEN(cos);
66 TESTIT_EVEN(cosh);
67 TESTIT_EVEN(fabs);
69 TESTIT_EVEN_C(ccos);
70 TESTIT_EVEN_C(ccosh);
71 TESTIT_EVEN_C(cabs);
73 TESTIT_EVEN_I(abs, i);
74 TESTIT_EVEN_I(imaxabs, im);
75 TESTIT_EVEN_I(labs, l);
76 TESTIT_EVEN_I(llabs, ll);
78 TESTIT_ODD(asin);
79 TESTIT_ODD(asinh);
80 TESTIT_ODD(atan);
81 TESTIT_ODD(atanh);
82 TESTIT_ODD(cbrt);
83 TESTIT_ODD(erf);
84 TESTIT_ODD(llrint);
85 TESTIT_ODD(llround);
86 TESTIT_ODD(lrint);
87 TESTIT_ODD(lround);
88 TESTIT_ODD(nearbyint);
89 TESTIT_ODD(rint);
90 TESTIT_ODD(round);
91 TESTIT_ODD(sin);
92 TESTIT_ODD(sinh);
93 TESTIT_ODD(tan);
94 TESTIT_ODD(tanh);
95 TESTIT_ODD(trunc);
97 TESTIT_ODD_C(casin);
98 TESTIT_ODD_C(casinh);
99 TESTIT_ODD_C(catan);
100 TESTIT_ODD_C(catanh);
101 TESTIT_ODD_C(cproj);
102 TESTIT_ODD_C(csin);
103 TESTIT_ODD_C(csinh);
104 TESTIT_ODD_C(ctan);
105 TESTIT_ODD_C(ctanh);
108 int main()
110 foo (1,1,1,1,1,1,1,1,1,1);
111 return 0;