diff options
author | Joseph Myers <joseph@codesourcery.com> | 2013-11-21 16:20:28 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2013-11-21 16:20:28 +0000 |
commit | 3c8e8595edb357b7ff80c86c46f79823ed1ecce1 (patch) | |
tree | 83b4eb3d53777452e702fa4c144848ae515b5422 /gcc | |
parent | 15e693cc593824fa56a2e52b756e1e2e4bad2a27 (diff) | |
download | gcc-3c8e8595edb357b7ff80c86c46f79823ed1ecce1.zip gcc-3c8e8595edb357b7ff80c86c46f79823ed1ecce1.tar.gz gcc-3c8e8595edb357b7ff80c86c46f79823ed1ecce1.tar.bz2 |
re PR rtl-optimization/55950 (Invalid sqrt constant propagation with -frounding-mode)
PR rtl-optimization/55950
* real.c (real_sqrt): Remove function.
* real.h (real_sqrt): Remove prototype.
* simplify-rtx.c (simplify_const_unary_operation): Do not fold
SQRT using real_sqrt.
From-SVN: r205223
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/real.c | 78 | ||||
-rw-r--r-- | gcc/real.h | 4 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 8 |
4 files changed, 10 insertions, 88 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7472098..a16ae68 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2013-11-21 Joseph Myers <joseph@codesourcery.com> + + PR rtl-optimization/55950 + * real.c (real_sqrt): Remove function. + * real.h (real_sqrt): Remove prototype. + * simplify-rtx.c (simplify_const_unary_operation): Do not fold + SQRT using real_sqrt. + 2013-11-21 Richard Biener <rguenther@suse.de> PR tree-optimization/59058 @@ -4765,84 +4765,6 @@ const struct real_format real_internal_format = false }; -/* Calculate the square root of X in mode MODE, and store the result - in R. Return TRUE if the operation does not raise an exception. - For details see "High Precision Division and Square Root", - Alan H. Karp and Peter Markstein, HP Lab Report 93-93-42, June - 1993. http://www.hpl.hp.com/techreports/93/HPL-93-42.pdf. */ - -bool -real_sqrt (REAL_VALUE_TYPE *r, enum machine_mode mode, - const REAL_VALUE_TYPE *x) -{ - static REAL_VALUE_TYPE halfthree; - static bool init = false; - REAL_VALUE_TYPE h, t, i; - int iter, exp; - - /* sqrt(-0.0) is -0.0. */ - if (real_isnegzero (x)) - { - *r = *x; - return false; - } - - /* Negative arguments return NaN. */ - if (real_isneg (x)) - { - get_canonical_qnan (r, 0); - return false; - } - - /* Infinity and NaN return themselves. */ - if (!real_isfinite (x)) - { - *r = *x; - return false; - } - - if (!init) - { - do_add (&halfthree, &dconst1, &dconsthalf, 0); - init = true; - } - - /* Initial guess for reciprocal sqrt, i. */ - exp = real_exponent (x); - real_ldexp (&i, &dconst1, -exp/2); - - /* Newton's iteration for reciprocal sqrt, i. */ - for (iter = 0; iter < 16; iter++) - { - /* i(n+1) = i(n) * (1.5 - 0.5*i(n)*i(n)*x). */ - do_multiply (&t, x, &i); - do_multiply (&h, &t, &i); - do_multiply (&t, &h, &dconsthalf); - do_add (&h, &halfthree, &t, 1); - do_multiply (&t, &i, &h); - - /* Check for early convergence. */ - if (iter >= 6 && real_identical (&i, &t)) - break; - - /* ??? Unroll loop to avoid copying. */ - i = t; - } - - /* Final iteration: r = i*x + 0.5*i*x*(1.0 - i*(i*x)). */ - do_multiply (&t, x, &i); - do_multiply (&h, &t, &i); - do_add (&i, &dconst1, &h, 1); - do_multiply (&h, &t, &i); - do_multiply (&i, &dconsthalf, &h); - do_add (&h, &t, &i, 0); - - /* ??? We need a Tuckerman test to get the last bit. */ - - real_convert (r, mode, &h); - return true; -} - /* Calculate X raised to the integer exponent N in mode MODE and store the result in R. Return true if the result may be inexact due to loss of precision. The algorithm is the classic "left-to-right binary @@ -461,10 +461,6 @@ bool real_can_shorten_arithmetic (enum machine_mode, enum machine_mode); /* In tree.c: wrap up a REAL_VALUE_TYPE in a tree node. */ extern tree build_real (tree, REAL_VALUE_TYPE); -/* Calculate R as the square root of X in the given machine mode. */ -extern bool real_sqrt (REAL_VALUE_TYPE *, enum machine_mode, - const REAL_VALUE_TYPE *); - /* Calculate R as X raised to the integer exponent N in mode MODE. */ extern bool real_powi (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *, HOST_WIDE_INT); diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 791f90d..ec13858 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1931,17 +1931,13 @@ simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode, && SCALAR_FLOAT_MODE_P (mode) && SCALAR_FLOAT_MODE_P (GET_MODE (op))) { - REAL_VALUE_TYPE d, t; + REAL_VALUE_TYPE d; REAL_VALUE_FROM_CONST_DOUBLE (d, op); switch (code) { case SQRT: - if (HONOR_SNANS (mode) && real_isnan (&d)) - return 0; - real_sqrt (&t, mode, &d); - d = t; - break; + return 0; case ABS: d = real_value_abs (&d); break; |