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-integral-1.c] - Blame information for rev 149

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 integral FP expressions are optimized.
4
 
5
   Written by Kaveh Ghazi, 2004-03-16.  */
6
 
7
/* { dg-do link } */
8
/* We need -ffinite-math-only so that we can fold "foo != foo", where
9
   foo is a floating point expression.  We need -fno-math-errno so
10
   that various math functions are marked const/pure and can be
11
   folded.  */
12
/* { dg-options "-ffinite-math-only -fno-math-errno" } */
13
 
14
extern int link_failure (int);
15
 
16
/* Test that the various FP truncation builtins detect integral
17
   arguments.  */
18
#define CHECK_FN(MATHFN) \
19
 if (__builtin_##MATHFN(i1) != i1) link_failure (__LINE__); \
20
 if (__builtin_##MATHFN##f(i1) != i1) link_failure (__LINE__); \
21
 if (__builtin_##MATHFN##l(i1) != i1) link_failure (__LINE__);
22
 
23
#define CHECK_FN_RET(MATHFN, RET) \
24
 if (__builtin_##MATHFN(i1) != (RET)(double)i1) link_failure (__LINE__); \
25
 if (__builtin_##MATHFN##f(i1) != (RET)(float)i1) link_failure (__LINE__); \
26
 if (__builtin_##MATHFN##l(i1) != (RET)(long double)i1) link_failure (__LINE__);
27
 
28
  /* Check that various other integral expressions are detected.  */
29
#define CHECK_EXPR(EXPR,NAME) \
30
 if (__builtin_ceill(EXPR) != (EXPR)) link_failure (__LINE__); \
31
 if (__builtin_lroundl(EXPR) != (long)(long double)(EXPR)) link_failure (__LINE__);
32
 
33
void __attribute__ ((__noinline__)) test (int i1, int i2)
34
{
35
  CHECK_FN(ceil);
36
  CHECK_FN(floor);
37
  CHECK_FN(nearbyint);
38
  CHECK_FN(rint);
39
  CHECK_FN(round);
40
  CHECK_FN(trunc);
41
  CHECK_FN_RET(lround, long);
42
  CHECK_FN_RET(llround, long long);
43
  CHECK_FN_RET(lrint, long);
44
  CHECK_FN_RET(llrint, long long);
45
  CHECK_FN_RET(lceil, long);
46
  CHECK_FN_RET(llceil, long long);
47
  CHECK_FN_RET(lfloor, long);
48
  CHECK_FN_RET(llfloor, long long);
49
 
50
  CHECK_EXPR (5.0, REAL_CST);
51
  CHECK_EXPR (5.0F, REAL_CSTf);
52
  CHECK_EXPR (5.0L, REAL_CSTl);
53
  CHECK_EXPR ((double)i1, FLOAT_EXPR);
54
  CHECK_EXPR ((float)i1, FLOAT_EXPRf);
55
  CHECK_EXPR ((long double)i1, FLOAT_EXPRl);
56
  CHECK_EXPR (__builtin_fabs(i1), ABS_EXPR);
57
  CHECK_EXPR (__builtin_fabsf(i1), ABS_EXPRf);
58
  CHECK_EXPR (__builtin_fabsl(i1), ABS_EXPRl);
59
  CHECK_EXPR (((void)i1,(double)i2), COMPOUND_EXPR);
60
  CHECK_EXPR ((double)i1+i2, PLUS_EXPR);
61
  CHECK_EXPR ((double)i1-i2, MINUS_EXPR);
62
  CHECK_EXPR ((double)i1*i2, MULT_EXPR);
63
}
64
 
65
int main (void)
66
{
67
  test (1, 2);
68
  return 0;
69
}

powered by: WebSVN 2.1.0

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