re PR middle-end/29335 (transcendental functions with constant arguments should be resolved at compile-time)

PR middle-end/29335
	* builtins.c (fold_builtin_1): Evaluate tgamma using MPFR.

testsuite:
	* gcc.dg/torture/builtin-math-2.c: Add tgamma tests.
	* gcc.dg/torture/builtin-math-3.c: Likewise.

From-SVN: r118200
This commit is contained in:
Kaveh R. Ghazi 2006-10-30 20:21:59 +00:00 committed by Kaveh Ghazi
parent ff81aa23e5
commit 61fb309f70
5 changed files with 41 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2006-10-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR middle-end/29335
* builtins.c (fold_builtin_1): Evaluate tgamma using MPFR.
2006-10-30 Pete Steinmetz <steinmtz@us.ibm.com>
* recog.c (store_data_bypass_p): Add support to allow IN_INSN to

View File

@ -9121,6 +9121,12 @@ fold_builtin_1 (tree fndecl, tree arglist, bool ignore)
NULL, NULL, 0);
break;
CASE_FLT_FN (BUILT_IN_TGAMMA):
if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE))
return do_mpfr_arg1 (TREE_VALUE (arglist), type, mpfr_gamma,
NULL, NULL, 0);
break;
CASE_FLT_FN (BUILT_IN_EXP):
return fold_builtin_exponent (fndecl, arglist, mpfr_exp);

View File

@ -1,3 +1,8 @@
2006-10-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-math-2.c: Add tgamma tests.
* gcc.dg/torture/builtin-math-3.c: Likewise.
2006-10-30 Tobias Burnus <burnus@net-b.de>
PR fortran/29452

View File

@ -90,6 +90,13 @@ void bar()
TESTIT (log1p, -2.0);
TESTIT (log1p, -1.0);
/* The tgamma arg errors with zero or negative integers. */
TESTIT (tgamma, 0.0);
TESTIT (tgamma, -0.0);
TESTIT (tgamma, -1.0);
TESTIT (tgamma, -2.0);
TESTIT (tgamma, -3.0);
/* An argument of NaN is not evaluated at compile-time. */
foof (__builtin_powf (__builtin_nanf(""), 2.5F));
foo (__builtin_pow (__builtin_nan(""), 2.5));
@ -155,6 +162,9 @@ void bar()
/* { dg-final { scan-tree-dump-times "log1p " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "log1pf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "log1pl" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "tgamma " 5 "original" } } */
/* { dg-final { scan-tree-dump-times "tgammaf" 5 "original" } } */
/* { dg-final { scan-tree-dump-times "tgammal" 5 "original" } } */
/* { dg-final { scan-tree-dump-times "pow " 13 "original" } } */
/* { dg-final { scan-tree-dump-times "powf" 13 "original" } } */
/* { dg-final { scan-tree-dump-times "powl" 13 "original" } } */

View File

@ -175,6 +175,21 @@ int main (void)
TESTIT_R (erfc, 1.0, 0.15, 0.16); /* erfc(1) == 0.157... */
TESTIT_R (erfc, -1.0, 1.84, 1.85); /* erfc(-1) == 1.842... */
TESTIT_R (tgamma, -4.5, -0.061, -0.060); /* tgamma(-4.5) == -0.06001... */
TESTIT_R (tgamma, -3.5, 0.27, 0.28); /* tgamma(-3.5) == 0.27008... */
TESTIT_R (tgamma, -2.5, -0.95, -0.94); /* tgamma(-2.5) == -0.945... */
TESTIT_R (tgamma, -1.5, 2.36, 2.37); /* tgamma(-1.5) == 2.363... */
TESTIT_R (tgamma, -0.5, -3.55, -3.54); /* tgamma(-0.5) == -3.544... */
TESTIT_R (tgamma, 0.5, 1.77, 1.78); /* tgamma(0.5) == 1.772... */
TESTIT (tgamma, 1.0, 1.0); /* tgamma(1) == 1 */
TESTIT_R (tgamma, 1.5, 0.88, 0.89); /* tgamma(1.5) == 0.886... */
TESTIT (tgamma, 2.0, 1.0); /* tgamma(2) == 1 */
TESTIT_R (tgamma, 2.5, 1.32, 1.33); /* tgamma(2.5) == 1.329... */
TESTIT (tgamma, 3.0, 2.0); /* tgamma(3) == 2 */
TESTIT_R (tgamma, 3.5, 3.32, 3.33); /* tgamma(3.5) == 3.323... */
TESTIT (tgamma, 4.0, 6.0); /* tgamma(4) == 6 */
TESTIT_R (tgamma, 4.5, 11.63, 11.64); /* tgamma(4.5) == 11.631... */
TESTIT2 (pow, 3.0, 4.0, 81.0); /* pow(3,4) == 81 */
TESTIT2 (pow, -3.0, 5.0, -243.0); /* pow(-3,5) == -243 */
TESTIT2 (pow, 16.0, 0.25, 2.0); /* pow(16,1/4) == 2 */