OSDN Git Service

* builtins.c (fold_builtin_logarithm): if N can't be truncated to
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Sep 2003 22:51:20 +0000 (22:51 +0000)
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Sep 2003 22:51:20 +0000 (22:51 +0000)
MODE exactly, then only convert logN(N) -> 1.0 if
flag_unsafe_math_optimizations is set.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71322 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c

index d6d7624..df66b3e 100644 (file)
@@ -1,5 +1,9 @@
 2003-09-11  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
+       * 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.
+
        * builtins.c (builtin_dconsts_init, dconstpi, dconste,
        init_builtin_dconsts): Delete.
        * emit-rtl.c (dconstpi, dconste): Define.
index 4df0e95..2e8189d 100644 (file)
@@ -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