summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-07 14:24:11 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-07 14:24:11 +0000
commit5a84ba55a56a2df5d389a73adf84d8fa7282cd97 (patch)
tree27722767a56435a8b6d77614d6158841f046d493
parentc43a8a1a732928bf9e1c35fb60b634fd6a66b750 (diff)
downloadppe42-gcc-5a84ba55a56a2df5d389a73adf84d8fa7282cd97.tar.gz
ppe42-gcc-5a84ba55a56a2df5d389a73adf84d8fa7282cd97.zip
2006-12-07 Richard Guenther <rguenther@suse.de>
* builtins.c (expand_builtin_pow): Adjust predicates for pow to cbrt expansion to unsafe math and !HONOR_NANS for negative base. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119622 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/builtins.c11
2 files changed, 14 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4c63be49300..0926c1dc550 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-07 Richard Guenther <rguenther@suse.de>
+
+ * builtins.c (expand_builtin_pow): Adjust predicates for
+ pow to cbrt expansion to unsafe math and !HONOR_NANS for
+ negative base.
+
2006-12-07 Jan Hubicka <jh@suse.cz>
* i386.c (nocona_cost, pentium4_cost): Update preffered memcpy/memset
diff --git a/gcc/builtins.c b/gcc/builtins.c
index fa7ed0133ba..3c7d1052cba 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2679,9 +2679,15 @@ expand_builtin_pow (tree exp, rtx target, rtx subtarget)
}
/* Try if the exponent is a third of an integer. In this case
- we can expand to x**(n/3) * cbrt(x)**(n%3). */
+ we can expand to x**(n/3) * cbrt(x)**(n%3). As cbrt (x) is
+ different from pow (x, 1./3.) due to rounding and behavior
+ with negative x we need to constrain this transformation to
+ unsafe math and positive x or finite math. */
fn = mathfn_built_in (type, BUILT_IN_CBRT);
- if (fn != NULL_TREE)
+ if (fn != NULL_TREE
+ && flag_unsafe_math_optimizations
+ && (tree_expr_nonnegative_p (arg0)
+ || !HONOR_NANS (mode)))
{
real_arithmetic (&c2, MULT_EXPR, &c, &dconst3);
real_round (&c2, mode, &c2);
@@ -2691,7 +2697,6 @@ expand_builtin_pow (tree exp, rtx target, rtx subtarget)
real_convert (&c2, mode, &c2);
if (real_identical (&c2, &c)
&& ((!optimize_size
- && flag_unsafe_math_optimizations
&& powi_cost (n/3) <= POWI_MAX_MULTS)
|| n == 1))
{
OpenPOWER on IntegriCloud