diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/torture/builtin-integral-1.c | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/builtin-integral-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/builtin-integral-1.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c b/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c new file mode 100644 index 000000000..522646dd5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/builtin-integral-1.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that integral FP expressions are optimized. + + Written by Kaveh Ghazi, 2004-03-16. */ + +/* { dg-do link } */ +/* We need -ffinite-math-only so that we can fold "foo != foo", where + foo is a floating point expression. We need -fno-math-errno so + that various math functions are marked const/pure and can be + folded. */ +/* { dg-options "-ffinite-math-only -fno-math-errno" } */ + +extern int link_failure (int); + +/* Test that the various FP truncation builtins detect integral + arguments. */ +#define CHECK_FN(MATHFN) \ + if (__builtin_##MATHFN(i1) != i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##f(i1) != i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##l(i1) != i1) link_failure (__LINE__); + +#define CHECK_FN_RET(MATHFN, RET) \ + if (__builtin_##MATHFN(i1) != (RET)(double)i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##f(i1) != (RET)(float)i1) link_failure (__LINE__); \ + if (__builtin_##MATHFN##l(i1) != (RET)(long double)i1) link_failure (__LINE__); + + /* Check that various other integral expressions are detected. */ +#define CHECK_EXPR(EXPR,NAME) \ + if (__builtin_ceill(EXPR) != (EXPR)) link_failure (__LINE__); \ + if (__builtin_lroundl(EXPR) != (long)(long double)(EXPR)) link_failure (__LINE__); + +void __attribute__ ((__noinline__)) test (int i1, int i2) +{ + CHECK_FN(ceil); + CHECK_FN(floor); + CHECK_FN(nearbyint); + CHECK_FN(rint); + CHECK_FN(round); + CHECK_FN(trunc); + CHECK_FN_RET(lround, long); + CHECK_FN_RET(llround, long long); + CHECK_FN_RET(lrint, long); + CHECK_FN_RET(llrint, long long); + CHECK_FN_RET(lceil, long); + CHECK_FN_RET(llceil, long long); + CHECK_FN_RET(lfloor, long); + CHECK_FN_RET(llfloor, long long); + + CHECK_EXPR (5.0, REAL_CST); + CHECK_EXPR (5.0F, REAL_CSTf); + CHECK_EXPR (5.0L, REAL_CSTl); + CHECK_EXPR ((double)i1, FLOAT_EXPR); + CHECK_EXPR ((float)i1, FLOAT_EXPRf); + CHECK_EXPR ((long double)i1, FLOAT_EXPRl); + CHECK_EXPR (__builtin_fabs(i1), ABS_EXPR); + CHECK_EXPR (__builtin_fabsf(i1), ABS_EXPRf); + CHECK_EXPR (__builtin_fabsl(i1), ABS_EXPRl); + CHECK_EXPR (((void)i1,(double)i2), COMPOUND_EXPR); + CHECK_EXPR ((double)i1+i2, PLUS_EXPR); + CHECK_EXPR ((double)i1-i2, MINUS_EXPR); + CHECK_EXPR ((double)i1*i2, MULT_EXPR); +} + +int main (void) +{ + test (1, 2); + return 0; +} |