From 4ba0d4dbb2ea51e47cd8c4a46c4a6674b5eb5862 Mon Sep 17 00:00:00 2001 From: jsm28 Date: Thu, 21 Nov 2013 16:20:28 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205223 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++ gcc/real.c | 78 ------------------------------------------------------ gcc/real.h | 4 --- gcc/simplify-rtx.c | 8 ++---- 4 files changed, 10 insertions(+), 88 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7472098bbe5..a16ae684f91 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2013-11-21 Joseph Myers + + 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 PR tree-optimization/59058 diff --git a/gcc/real.c b/gcc/real.c index 82f3ba61c10..c1af548b44f 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -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 diff --git a/gcc/real.h b/gcc/real.h index b92453411d7..c4e036e9ff5 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -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 791f90dca2b..ec138584c38 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; -- 2.11.4.GIT