OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [builtin-convert-1.c] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Copyright (C) 2004  Free Software Foundation.
2
 
3
   Verify that built-in math function conversion to smaller FP types
4
   is correctly performed by the compiler.
5
 
6
   Written by Kaveh Ghazi, 2004-03-17.  */
7
 
8
/* { dg-do link } */
9
/* { dg-options "-ffast-math" } */
10
/* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
11
/* { dg-options "-ffast-math -std=c99" { target *-*-solaris2* } } */
12
 
13
#include "../builtins-config.h"
14
 
15
/* This check is necessary when converting to a C99 function.  */
16
#ifdef HAVE_C99_RUNTIME
17
#define C99CODE(CODE) (CODE)
18
#define MAYBEC99(CODE, C99) (CODE)
19
#else
20
#define C99CODE(CODE) 0
21
#define MAYBEC99(CODE, C99) (!(C99) && (CODE))
22
#endif
23
 
24
void test(double d1, float f1, long double ld1)
25
{
26
  /* Test converting math builtins to narrower FP types based on a
27
     narrowing cast on the outside of the call.  MATHFN is the
28
     function to test, and C99 is 0/1 depending on whether the
29
     `double' version of MATHFN is a C99 function.  The optimization
30
     is only performed if the replacement function is actually
31
     narrower in width, so check that first.  */
32
#define OUTER_CAST1(MATHFN, C99) \
33
 extern void link_failure_outer_##MATHFN##l_##MATHFN##_1(void); \
34
 extern void link_failure_outer_##MATHFN##l_##MATHFN##_2(void); \
35
 extern void link_failure_outer_##MATHFN##l_##MATHFN##f_1(void); \
36
 extern void link_failure_outer_##MATHFN##l_##MATHFN##f_2(void); \
37
 extern void link_failure_outer_##MATHFN##_##MATHFN##f_1(void); \
38
 extern void link_failure_outer_##MATHFN##_##MATHFN##f_2(void); \
39
 if (sizeof (long double) > sizeof (double) \
40
     && MAYBEC99 ((double) __builtin_##MATHFN##l((double)ld1) != __builtin_##MATHFN(ld1), C99)) \
41
    link_failure_outer_##MATHFN##l_##MATHFN##_1(); \
42
 if (sizeof (long double) > sizeof (double) \
43
     && MAYBEC99 ((double) __builtin_##MATHFN##l(d1) != __builtin_##MATHFN(d1), C99)) \
44
    link_failure_outer_##MATHFN##l_##MATHFN##_1(); \
45
 if (sizeof (long double) > sizeof (double) \
46
     && MAYBEC99 ((double) __builtin_##MATHFN##l(f1) != __builtin_##MATHFN(f1), C99)) \
47
    link_failure_outer_##MATHFN##l_##MATHFN##_2(); \
48
 if (sizeof (long double) > sizeof (float) \
49
     && C99CODE ((float) __builtin_##MATHFN##l((float) ld1) != __builtin_##MATHFN##f(ld1))) \
50
    link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \
51
 if (sizeof (long double) > sizeof (float) \
52
     && C99CODE ((float) __builtin_##MATHFN##l((float) d1) != __builtin_##MATHFN##f(d1))) \
53
    link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \
54
 if (sizeof (long double) > sizeof (float) \
55
     && C99CODE ((float) __builtin_##MATHFN##l(f1) != __builtin_##MATHFN##f(f1))) \
56
    link_failure_outer_##MATHFN##l_##MATHFN##f_2(); \
57
 if (sizeof (double) > sizeof (float) \
58
     && C99CODE ((float) __builtin_##MATHFN((float) ld1) != __builtin_##MATHFN##f(ld1))) \
59
    link_failure_outer_##MATHFN##_##MATHFN##f_1(); \
60
 if (sizeof (double) > sizeof (float) \
61
     && C99CODE ((float) __builtin_##MATHFN((float) d1) != __builtin_##MATHFN##f(d1))) \
62
    link_failure_outer_##MATHFN##_##MATHFN##f_1(); \
63
 if (sizeof (double) > sizeof (float) \
64
     && C99CODE ((float) __builtin_##MATHFN(f1) != __builtin_##MATHFN##f(f1))) \
65
    link_failure_outer_##MATHFN##_##MATHFN##f_2()
66
 
67
  /* Test converting math builtins to narrower FP types based on if
68
     the argument is a narrower type (perhaps implicitly) cast to a
69
     wider one.  */
70
#define INNER_CAST1(MATHFN, C99) \
71
 extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \
72
 extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \
73
 extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \
74
 if (sizeof (long double) > sizeof (double) \
75
     && MAYBEC99 (__builtin_##MATHFN##l(d1) != (long double) __builtin_##MATHFN(d1), C99)) \
76
    link_failure_inner_##MATHFN##l_##MATHFN(); \
77
 if (sizeof (long double) > sizeof (float) \
78
     && C99CODE (__builtin_##MATHFN##l(f1) != (long double) __builtin_##MATHFN##f(f1))) \
79
    link_failure_inner_##MATHFN##l_##MATHFN##f(); \
80
 if (sizeof (long double) > sizeof (float) \
81
     && C99CODE (__builtin_##MATHFN##l((double)f1) != (long double) __builtin_##MATHFN##f(f1))) \
82
    link_failure_inner_##MATHFN##l_##MATHFN##f(); \
83
 if (sizeof (double) > sizeof (float) \
84
     && C99CODE (__builtin_##MATHFN(f1) != (double) __builtin_##MATHFN##f(f1))) \
85
    link_failure_inner_##MATHFN##_##MATHFN##f()
86
 
87
 
88
#ifdef __OPTIMIZE__
89
  OUTER_CAST1 (acos, /*C99=*/ 0);
90
  OUTER_CAST1 (acosh, /*C99=*/ 1);
91
  OUTER_CAST1 (asin, /*C99=*/ 1);
92
  OUTER_CAST1 (asinh, /*C99=*/ 1);
93
  OUTER_CAST1 (atan, /*C99=*/ 0);
94
  OUTER_CAST1 (atanh, /*C99=*/ 1);
95
  OUTER_CAST1 (cbrt, /*C99=*/ 1);
96
  OUTER_CAST1 (cos, /*C99=*/ 0);
97
  OUTER_CAST1 (cosh, /*C99=*/ 0);
98
  OUTER_CAST1 (erf, /*C99=*/ 1);
99
  OUTER_CAST1 (erfc, /*C99=*/ 1);
100
  OUTER_CAST1 (exp, /*C99=*/ 0);
101
  OUTER_CAST1 (exp2, /*C99=*/ 1);
102
  OUTER_CAST1 (expm1, /*C99=*/ 1);
103
  OUTER_CAST1 (fabs, /*C99=*/ 0);
104
  OUTER_CAST1 (log, /*C99=*/ 0);
105
  OUTER_CAST1 (log10, /*C99=*/ 0);
106
  OUTER_CAST1 (log1p, /*C99=*/ 1);
107
  OUTER_CAST1 (log2, /*C99=*/ 1);
108
  OUTER_CAST1 (logb, /*C99=*/ 1);
109
  OUTER_CAST1 (sin, /*C99=*/ 0);
110
  OUTER_CAST1 (sinh, /*C99=*/ 0);
111
  OUTER_CAST1 (sqrt, /*C99=*/ 0);
112
  OUTER_CAST1 (tan, /*C99=*/ 0);
113
  OUTER_CAST1 (tanh, /*C99=*/ 0);
114
  OUTER_CAST1 (tgamma, /*C99=*/ 1);
115
 
116
  INNER_CAST1 (ceil, /*C99=*/ 0);
117
  OUTER_CAST1 (ceil, /*C99=*/ 0);
118
  INNER_CAST1 (floor, /*C99=*/ 0);
119
  OUTER_CAST1 (floor, /*C99=*/ 0);
120
  INNER_CAST1 (lceil, /*C99=*/ 1);
121
  OUTER_CAST1 (lceil, /*C99=*/ 1);
122
  INNER_CAST1 (lfloor, /*C99=*/ 1);
123
  OUTER_CAST1 (lfloor, /*C99=*/ 1);
124
  INNER_CAST1 (lrint, /*C99=*/ 1);
125
  OUTER_CAST1 (lrint, /*C99=*/ 1);
126
  INNER_CAST1 (lround, /*C99=*/ 1);
127
  OUTER_CAST1 (lround, /*C99=*/ 1);
128
  INNER_CAST1 (llceil, /*C99=*/ 1);
129
  OUTER_CAST1 (llceil, /*C99=*/ 1);
130
  INNER_CAST1 (llfloor, /*C99=*/ 1);
131
  OUTER_CAST1 (llfloor, /*C99=*/ 1);
132
  INNER_CAST1 (llrint, /*C99=*/ 1);
133
  OUTER_CAST1 (llrint, /*C99=*/ 1);
134
  INNER_CAST1 (llround, /*C99=*/ 1);
135
  OUTER_CAST1 (llround, /*C99=*/ 1);
136
  INNER_CAST1 (nearbyint, /*C99=*/ 1);
137
  OUTER_CAST1 (nearbyint, /*C99=*/ 1);
138
  INNER_CAST1 (rint, /*C99=*/ 1);
139
  OUTER_CAST1 (rint, /*C99=*/ 1);
140
  INNER_CAST1 (round, /*C99=*/ 1);
141
  OUTER_CAST1 (round, /*C99=*/ 1);
142
  INNER_CAST1 (trunc, /*C99=*/ 1);
143
  OUTER_CAST1 (trunc, /*C99=*/ 1);
144
#endif /* __OPTIMIZE__ */
145
}
146
 
147
int main (void)
148
{
149
  return 0;
150
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.