Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.dg / torture / builtin-integral-1.c
blob0aeb7ff7bdb4b007a7ea21577de7f0548bfbffa6
1 /* Copyright (C) 2004 Free Software Foundation.
3 Verify that integral FP expressions are optimized.
5 Written by Kaveh Ghazi, 2004-03-16. */
7 /* { dg-do link } */
8 /* { dg-options "-ffast-math" } */
10 #define PROTOTYPE1(FN) extern double FN(double); extern float FN##f(float); \
11 extern long double FN##l(long double);
12 #define PROTOTYPE1_RET(FN, RET) extern RET FN(double); extern RET FN##f(float); \
13 extern RET FN##l(long double);
14 #define PROTOTYPE_LINK_FAILURE(FN) extern void link_failure_##FN(void); \
15 extern void link_failure_##FN##f(void); \
16 extern void link_failure_##FN##l(void); \
18 PROTOTYPE1(fabs)
19 PROTOTYPE1(ceil)
20 PROTOTYPE1(floor)
21 PROTOTYPE1(nearbyint)
22 PROTOTYPE1(rint)
23 PROTOTYPE1(round)
24 PROTOTYPE1(trunc)
25 PROTOTYPE1_RET(lround, long)
26 PROTOTYPE1_RET(llround, long long)
27 PROTOTYPE1_RET(lrint, long)
28 PROTOTYPE1_RET(llrint, long long)
30 /* Test that the various FP truncation builtins detect integral
31 arguments. */
32 #define CHECK_FN(MATHFN) \
33 PROTOTYPE_LINK_FAILURE(MATHFN); \
34 if (MATHFN(i1) != i1) link_failure_##MATHFN(); \
35 if (MATHFN##f(i1) != i1) link_failure_##MATHFN##f(); \
36 if (MATHFN##l(i1) != i1) link_failure_##MATHFN##l();
38 #define CHECK_FN_RET(MATHFN, RET) \
39 PROTOTYPE_LINK_FAILURE(MATHFN); \
40 if (MATHFN(i1) != (RET)(double)i1) link_failure_##MATHFN(); \
41 if (MATHFN##f(i1) != (RET)(float)i1) link_failure_##MATHFN##f(); \
42 if (MATHFN##l(i1) != (RET)(long double)i1) link_failure_##MATHFN##l();
44 /* Check that various other integral expressions are detected. */
45 #define CHECK_EXPR(EXPR,NAME) \
46 extern void link_failure_FP_##NAME(void); \
47 extern void link_failure_fixed_##NAME(void); \
48 if (ceill(EXPR) != (EXPR)) link_failure_FP_##NAME(); \
49 if (lroundl(EXPR) != (long)(long double)(EXPR)) link_failure_fixed_##NAME();
51 void __attribute__ ((__noinline__)) test (int i1, int i2)
53 CHECK_FN(ceil);
54 CHECK_FN(floor);
55 CHECK_FN(nearbyint);
56 CHECK_FN(rint);
57 CHECK_FN(round);
58 CHECK_FN(trunc);
59 CHECK_FN_RET(lround, long);
60 CHECK_FN_RET(llround, long long);
61 CHECK_FN_RET(lrint, long);
62 CHECK_FN_RET(llrint, long long);
64 CHECK_EXPR (5.0, REAL_CST);
65 CHECK_EXPR (5.0F, REAL_CSTf);
66 CHECK_EXPR (5.0L, REAL_CSTl);
67 CHECK_EXPR ((double)i1, FLOAT_EXPR);
68 CHECK_EXPR ((float)i1, FLOAT_EXPRf);
69 CHECK_EXPR ((long double)i1, FLOAT_EXPRl);
70 CHECK_EXPR (fabs(i1), ABS_EXPR);
71 CHECK_EXPR (fabsf(i1), ABS_EXPRf);
72 CHECK_EXPR (fabsl(i1), ABS_EXPRl);
73 CHECK_EXPR (((void)i1,(double)i2), COMPOUND_EXPR);
74 CHECK_EXPR ((double)i1+i2, PLUS_EXPR);
75 CHECK_EXPR ((double)i1-i2, MINUS_EXPR);
76 CHECK_EXPR ((double)i1*i2, MULT_EXPR);
79 int main (void)
81 test (1, 2);
82 return 0;