Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.dg / torture / builtin-convert-2.c
blob5c4c4a6740350ab529c7825ab83fd8a5114b4a28
1 /* Copyright (C) 2004 Free Software Foundation.
3 Verify that built-in math function conversion into integer rounding
4 functions is correctly performed by the compiler.
6 Written by Kaveh ghazi, 2004-04-26. */
8 /* { dg-do link } */
9 /* { dg-options "-ffast-math" } */
10 /* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
12 #include "../builtins-config.h"
14 #define PROTOTYPE(FN) extern double FN(double); \
15 extern float FN##f(float); \
16 extern long double FN##l(long double);
17 #define PROTOTYPE_RET(FN, RET) extern RET FN(double); \
18 extern RET FN##f(float); \
19 extern RET FN##l(long double);
21 /* Macro to do all FP type combinations. The second half tests
22 narrowing the FP type. */
23 #define TEST_FP2FIXED(FN1, FN2) \
24 PROTOTYPE(FN1) \
25 PROTOTYPE_RET(FN2, long) \
26 PROTOTYPE_RET(l##FN2, long long) \
27 extern void link_error_##FN1##_##FN2(void); \
28 extern void link_error_##FN1##f_##FN2##f(void); \
29 extern void link_error_##FN1##l_##FN2##l(void); \
30 extern void link_error_##FN1##_l##FN2(void); \
31 extern void link_error_##FN1##f_l##FN2##f(void); \
32 extern void link_error_##FN1##l_l##FN2##l(void); \
33 if ((long)FN1(d) != FN2(d)) \
34 link_error_##FN1##_##FN2(); \
35 if ((long)FN1##f(f) != FN2##f(f)) \
36 link_error_##FN1##f_##FN2##f(); \
37 if ((long)FN1##l(ld) != FN2##l(ld)) \
38 link_error_##FN1##l_##FN2##l(); \
39 if ((long long)FN1(d) != l##FN2(d)) \
40 link_error_##FN1##_l##FN2(); \
41 if ((long long)FN1##f(f) != l##FN2##f(f)) \
42 link_error_##FN1##f_l##FN2##f(); \
43 if ((long long)FN1##l(ld) != l##FN2##l(ld)) \
44 link_error_##FN1##l_l##FN2##l(); \
45 extern void link_error_##FN1##_##FN2##f(void); \
46 extern void link_error_##FN1##l_##FN2(void); \
47 extern void link_error_##FN1##l_##FN2##f(void); \
48 extern void link_error_##FN1##_l##FN2##f(void); \
49 extern void link_error_##FN1##l_l##FN2(void); \
50 extern void link_error_##FN1##l_l##FN2##f(void); \
51 if (sizeof(double) > sizeof(float) && (long)FN1(f) != FN2##f(f)) \
52 link_error_##FN1##_##FN2##f(); \
53 if (sizeof(long double) > sizeof(double) && (long)FN1##l(d) != FN2(d)) \
54 link_error_##FN1##l_##FN2(); \
55 if (sizeof(long double) > sizeof(float) && (long)FN1##l(f) != FN2##f(f)) \
56 link_error_##FN1##l_##FN2##f(); \
57 if (sizeof(double) > sizeof(float) && (long long)FN1(f) != l##FN2##f(f)) \
58 link_error_##FN1##_l##FN2##f(); \
59 if (sizeof(long double) > sizeof(double) && (long long)FN1##l(d) != l##FN2(d)) \
60 link_error_##FN1##l_l##FN2(); \
61 if (sizeof(long double) > sizeof(float) && (long long)FN1##l(f) != l##FN2##f(f)) \
62 link_error_##FN1##l_l##FN2##f()
64 void __attribute__ ((__noinline__)) foo (double d, float f, long double ld)
66 #ifdef __OPTIMIZE__
67 # ifdef HAVE_C99_RUNTIME
68 /* The resulting transformation functions are all C99. */
69 TEST_FP2FIXED (round, lround);
70 TEST_FP2FIXED (nearbyint, lrint);
71 TEST_FP2FIXED (rint, lrint);
72 # endif
73 #endif
76 int main()
78 foo (1.0, 2.0, 3.0);
79 return 0;