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-3.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 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-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
#define PROTOTYPE1_RET(FN, RET) \
16
  extern RET FN(double); \
17
  extern RET FN##f(float); \
18
  extern RET FN##l(long double);
19
 
20
/* Test converting math builtins to narrower FP types based on if the
21
   argument is a narrower type (perhaps implicitly) cast to a wider
22
   one.  */
23
#define INNER_CAST1(MATHFN, RET) \
24
 PROTOTYPE1_RET (MATHFN, RET); \
25
 extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \
26
 extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \
27
 extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \
28
 if (sizeof (long double) > sizeof (double) \
29
     && MATHFN##l(d1) != MATHFN(d1)) \
30
    link_failure_inner_##MATHFN##l_##MATHFN(); \
31
 if (sizeof (long double) > sizeof (float) \
32
     && MATHFN##l(f1) != MATHFN##f(f1)) \
33
    link_failure_inner_##MATHFN##l_##MATHFN##f(); \
34
 if (sizeof (long double) > sizeof (float) \
35
     && MATHFN##l((double)f1) != MATHFN##f(f1)) \
36
    link_failure_inner_##MATHFN##l_##MATHFN##f(); \
37
 if (sizeof (double) > sizeof (float) \
38
     && MATHFN(f1) != MATHFN##f(f1)) \
39
    link_failure_inner_##MATHFN##_##MATHFN##f()
40
 
41
void __attribute__ ((__noinline__)) test (double d1, float f1)
42
{
43
#ifdef __OPTIMIZE__
44
#ifdef HAVE_C99_RUNTIME
45
  /* We're converting to implicitly generated C99 functions.  */
46
  INNER_CAST1 (__builtin_lceil, long);
47
  INNER_CAST1 (__builtin_llceil, long long);
48
  INNER_CAST1 (__builtin_lfloor, long);
49
  INNER_CAST1 (__builtin_llfloor, long long);
50
  INNER_CAST1 (lround, long);
51
  INNER_CAST1 (llround, long long);
52
  INNER_CAST1 (lrint, long);
53
  INNER_CAST1 (llrint, long long);
54
#endif /* HAVE_C99_RUNTIME */
55
#endif /* __OPTIMIZE__ */
56
}
57
 
58
int main (void)
59
{
60
  test (1, 2);
61
  return 0;
62
}

powered by: WebSVN 2.1.0

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