aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2006-10-30 20:21:59 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2006-10-30 20:21:59 +0000
commit61fb309f70ef6a4f034145bc3e274911e93a92e1 (patch)
treea54e7be62c04933fea70fa36cb64e800264525af
parentff81aa23e51c3d3c1fb52449c583bafeca04ca3f (diff)
downloadgcc-61fb309f70ef6a4f034145bc3e274911e93a92e1.zip
gcc-61fb309f70ef6a4f034145bc3e274911e93a92e1.tar.gz
gcc-61fb309f70ef6a4f034145bc3e274911e93a92e1.tar.bz2
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
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/builtins.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-2.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-3.c15
5 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c9b6244..87126bd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 3a71e04..2184c71 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f9da3e8..1c6b906 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-2.c b/gcc/testsuite/gcc.dg/torture/builtin-math-2.c
index a2213da..5b5d55a 100644
--- a/gcc/testsuite/gcc.dg/torture/builtin-math-2.c
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-2.c
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-3.c b/gcc/testsuite/gcc.dg/torture/builtin-math-3.c
index 3efe021..34e0272 100644
--- a/gcc/testsuite/gcc.dg/torture/builtin-math-3.c
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-3.c
@@ -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 */