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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [builtin-convert-3.c] - Blame information for rev 754

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

Line No. Rev Author Line
1 689 jeremybenn
/* Copyright (C) 2004  Free Software Foundation.
2
 
3
   Verify that builtin math functions (with fixed point return types)
4
   are converted to smaller FP types correctly by the compiler.
5
 
6
   Written by Kaveh Ghazi, 2004-05-01.  */
7
 
8
/* { dg-do link } */
9
/* { dg-options "-ffast-math" } */
10
/* { dg-add-options c99_runtime } */
11
 
12
#include "../builtins-config.h"
13
 
14
#define PROTOTYPE1_RET(FN, RET) \
15
  extern RET FN(double); \
16
  extern RET FN##f(float); \
17
  extern RET FN##l(long double);
18
 
19
/* Test converting math builtins to narrower FP types based on if the
20
   argument is a narrower type (perhaps implicitly) cast to a wider
21
   one.  */
22
#define INNER_CAST1(MATHFN, RET) \
23
 PROTOTYPE1_RET (MATHFN, RET); \
24
 extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \
25
 extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \
26
 extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \
27
 if (sizeof (long double) > sizeof (double) \
28
     && MATHFN##l(d1) != MATHFN(d1)) \
29
    link_failure_inner_##MATHFN##l_##MATHFN(); \
30
 if (sizeof (long double) > sizeof (float) \
31
     && MATHFN##l(f1) != MATHFN##f(f1)) \
32
    link_failure_inner_##MATHFN##l_##MATHFN##f(); \
33
 if (sizeof (long double) > sizeof (float) \
34
     && MATHFN##l((double)f1) != MATHFN##f(f1)) \
35
    link_failure_inner_##MATHFN##l_##MATHFN##f(); \
36
 if (sizeof (double) > sizeof (float) \
37
     && MATHFN(f1) != MATHFN##f(f1)) \
38
    link_failure_inner_##MATHFN##_##MATHFN##f()
39
 
40
void __attribute__ ((__noinline__)) test (double d1, float f1)
41
{
42
#ifdef __OPTIMIZE__
43
#ifdef HAVE_C99_RUNTIME
44
  /* We're converting to implicitly generated C99 functions.  */
45
  INNER_CAST1 (__builtin_lceil, long);
46
  INNER_CAST1 (__builtin_llceil, long long);
47
  INNER_CAST1 (__builtin_lfloor, long);
48
  INNER_CAST1 (__builtin_llfloor, long long);
49
  INNER_CAST1 (lround, long);
50
  INNER_CAST1 (llround, long long);
51
  INNER_CAST1 (lrint, long);
52
  INNER_CAST1 (llrint, long long);
53
#endif /* HAVE_C99_RUNTIME */
54
#endif /* __OPTIMIZE__ */
55
}
56
 
57
int main (void)
58
{
59
  test (1, 2);
60
  return 0;
61
}

powered by: WebSVN 2.1.0

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