diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2007-01-31 15:06:19 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2007-01-31 15:06:19 +0000 |
commit | 4fc784235047bf77dc7b8b05820ac8a596ea4142 (patch) | |
tree | b9b851f9784b75ef4fc4a39e72412270f9adf292 /gcc/builtins.c | |
parent | 677cc14d2d379a47a489cbbe14380983efe36884 (diff) | |
download | gcc-4fc784235047bf77dc7b8b05820ac8a596ea4142.zip gcc-4fc784235047bf77dc7b8b05820ac8a596ea4142.tar.gz gcc-4fc784235047bf77dc7b8b05820ac8a596ea4142.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_sqrt): Use MPFR for constant args.
testsuite:
* gcc.dg/torture/builtin-math-2.c: Add sqrt cases.
* gcc.dg/torture/builtin-math-3.c: Likewise.
From-SVN: r121423
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 777206c..9f51553 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -7200,22 +7200,15 @@ fold_builtin_sqrt (tree arglist, tree type) enum built_in_function fcode; tree arg = TREE_VALUE (arglist); - + tree res; + if (!validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) return NULL_TREE; - /* Optimize sqrt of constant value. */ - if (TREE_CODE (arg) == REAL_CST - && !TREE_OVERFLOW (arg)) - { - REAL_VALUE_TYPE r, x; - - x = TREE_REAL_CST (arg); - if (real_sqrt (&r, TYPE_MODE (type), &x) - || (!flag_trapping_math && !flag_errno_math)) - return build_real (type, r); - } - + /* Calculate the result when the argument is a constant. */ + if ((res = do_mpfr_arg1 (arg, type, mpfr_sqrt, &dconst0, NULL, true))) + return res; + /* Optimize sqrt(expN(x)) = expN(x*0.5). */ fcode = builtin_mathfn_code (arg); if (flag_unsafe_math_optimizations && BUILTIN_EXPONENT_P (fcode)) |