builtin-math-2.c: New test.

* gcc.dg/torture/builtin-math-2.c: New test.

From-SVN: r118003
This commit is contained in:
Kaveh R. Ghazi 2006-10-24 12:25:06 +00:00 committed by Kaveh Ghazi
parent 27d7d0422c
commit a5326b13ed
2 changed files with 71 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2006-10-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-math-2.c: New test.
2006-10-24 Richard Guenther <rguenther@suse.de>
PR middle-end/28796

View File

@ -0,0 +1,67 @@
/* Test things that should block GCC from optimizing compile-time
constants passed to a builtin transcendental function.
Origin: Kaveh R. Ghazi 10/22/2006. */
/* { dg-do compile } */
/* { dg-options "-fdump-tree-original" } */
extern void foof (float);
extern void foo (double);
extern void fool (long double);
void bar()
{
/* An argument of NaN is not evaluated at compile-time. */
foof (__builtin_exp2f (__builtin_nanf("")));
foo (__builtin_exp2 (__builtin_nan("")));
fool (__builtin_exp2l (__builtin_nanl("")));
/* An argument of Inf/-Inf is not evaluated at compile-time. */
foof (__builtin_exp2f (__builtin_inff()));
foo (__builtin_exp2 (__builtin_inf()));
fool (__builtin_exp2l (__builtin_infl()));
foof (__builtin_exp2f (-__builtin_inff()));
foo (__builtin_exp2 (-__builtin_inf()));
fool (__builtin_exp2l (-__builtin_infl()));
/* Result overflows MPFR, which in version 2.2.x has 30 exponent bits. */
foof (__builtin_exp2f (0x1p50F));
foo (__builtin_exp2 (0x1p50));
fool (__builtin_exp2l (0x1p50L));
/* Result underflows MPFR, which in version 2.2.x has 30 exponent bits. */
foof (__builtin_exp2f (-0x1p50F));
foo (__builtin_exp2 (-0x1p50));
fool (__builtin_exp2l (-0x1p50L));
/* Result overflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */
foof (__builtin_exp2f (0x1p28F));
foo (__builtin_exp2 (0x1p28));
fool (__builtin_exp2l (0x1p28L));
/* Result underflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */
foof (__builtin_exp2f (-0x1p28F));
foo (__builtin_exp2 (-0x1p28));
fool (__builtin_exp2l (-0x1p28L));
/* Result overflows (even an extended) C double's mode. */
foof (__builtin_exp2f (0x1p24F));
foo (__builtin_exp2 (0x1p24));
fool (__builtin_exp2l (0x1p24L));
/* Result underflows (even an extended) C double's mode. */
foof (__builtin_exp2f (-0x1p24F));
foo (__builtin_exp2 (-0x1p24));
fool (__builtin_exp2l (-0x1p24L));
/* Ensure that normal arguments/results are folded. */
foof (__builtin_exp2f (1.5F));
foo (__builtin_exp2 (1.5));
fool (__builtin_exp2l (1.5L));
foof (__builtin_exp2f (-1.5F));
foo (__builtin_exp2 (-1.5));
fool (__builtin_exp2l (-1.5L));
}
/* { dg-final { scan-tree-dump-times "exp2 " 9 "original" } } */
/* { dg-final { scan-tree-dump-times "exp2f" 9 "original" } } */
/* { dg-final { scan-tree-dump-times "exp2l" 9 "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */