diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-31 15:06:19 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-31 15:06:19 +0000 |
commit | b4e8ab0c6a2c824cacbbb668321232fbc84b5bd4 (patch) | |
tree | b9b851f9784b75ef4fc4a39e72412270f9adf292 /gcc/builtins.c | |
parent | 3bbbcdff3d9d98e86abbd8ce8090b8fbb518bfba (diff) | |
download | gcc-b4e8ab0c6a2c824cacbbb668321232fbc84b5bd4.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121423 138bc75d-0d04-0410-961f-82ee72b054a4
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 777206c83a0..9f51553d0e5 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)) |