diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2003-09-11 22:51:20 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2003-09-11 22:51:20 +0000 |
commit | fe27b7cc414a7b57ef801872157b596f4f39c1f6 (patch) | |
tree | 468ba5ac0830c30d6b8f6e34fa94e86f02f19f5b /gcc/builtins.c | |
parent | ab01a87cbc7872383eff0faa4c1cc53271ff6e85 (diff) | |
download | gcc-fe27b7cc414a7b57ef801872157b596f4f39c1f6.tar.gz |
builtins.c (fold_builtin_logarithm): if N can't be truncated to MODE exactly...
* builtins.c (fold_builtin_logarithm): if N can't be truncated to
MODE exactly, then only convert logN(N) -> 1.0 if
flag_unsafe_math_optimizations is set.
From-SVN: r71322
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 4df0e95b7f6..2e8189d106c 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5949,16 +5949,21 @@ fold_builtin_logarithm (tree exp, const REAL_VALUE_TYPE *value) tree type = TREE_TYPE (TREE_TYPE (fndecl)); tree arg = TREE_VALUE (arglist); const enum built_in_function fcode = builtin_mathfn_code (arg); - const REAL_VALUE_TYPE value_mode = - real_value_truncate (TYPE_MODE (type), *value); /* Optimize log*(1.0) = 0.0. */ if (real_onep (arg)) return build_real (type, dconst0); - /* Optimize logN(N) = 1.0. */ - if (real_dconstp (arg, &value_mode)) - return build_real (type, dconst1); + /* Optimize logN(N) = 1.0. If N can't be truncated to MODE + exactly, then only do this if flag_unsafe_math_optimizations. */ + if (exact_real_truncate (TYPE_MODE (type), value) + || flag_unsafe_math_optimizations) + { + const REAL_VALUE_TYPE value_truncate = + real_value_truncate (TYPE_MODE (type), *value); + if (real_dconstp (arg, &value_truncate)) + return build_real (type, dconst1); + } /* Special case, optimize logN(expN(x)) = x. */ if (flag_unsafe_math_optimizations |