builtins.c (fold_builtin_cabs, [...]): Use `mathfn_built_in' to determine the new...
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Wed, 14 Apr 2004 14:29:35 +0000 (14:29 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Wed, 14 Apr 2004 14:29:35 +0000 (14:29 +0000)
* builtins.c (fold_builtin_cabs, fold_builtin): Use
`mathfn_built_in' to determine the new builtin.
* fold-const.c (fold): Likewise.

From-SVN: r80680

gcc/ChangeLog
gcc/builtins.c
gcc/fold-const.c

index b749c71f19d451a681eb34a475d082da205eab3e..00c65114eb2c213a5e301597d151c75a250deb71 100644 (file)
@@ -1,3 +1,9 @@
+2004-04-14  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * builtins.c (fold_builtin_cabs, fold_builtin): Use
+       `mathfn_built_in' to determine the new builtin.
+       * fold-const.c (fold): Likewise.
+
 2004-04-14  Richard Sandiford  <rsandifo@redhat.com>
 
        * doc/invoke.texi: Rename MIPS's -mfix-vr4122-bugs to -mfix-vr4120.
index fbc1a0023d20c58cd9f7fb7bd21e73bbcb78458e..184711bbc4b4eea909edd6b92dd575f43a0ae740 100644 (file)
@@ -5973,18 +5973,7 @@ fold_builtin_cabs (tree fndecl, tree arglist, tree type)
 
   if (flag_unsafe_math_optimizations)
     {
-      enum built_in_function fcode;
-      tree sqrtfn;
-
-      fcode = DECL_FUNCTION_CODE (fndecl);
-      if (fcode == BUILT_IN_CABS)
-       sqrtfn = implicit_built_in_decls[BUILT_IN_SQRT];
-      else if (fcode == BUILT_IN_CABSF)
-       sqrtfn = implicit_built_in_decls[BUILT_IN_SQRTF];
-      else if (fcode == BUILT_IN_CABSL)
-       sqrtfn = implicit_built_in_decls[BUILT_IN_SQRTL];
-      else
-       sqrtfn = NULL_TREE;
+      tree sqrtfn = mathfn_built_in (type, BUILT_IN_SQRT);
 
       if (sqrtfn != NULL_TREE)
        {
@@ -7097,17 +7086,7 @@ fold_builtin (tree exp)
              if (flag_unsafe_math_optimizations
                  && REAL_VALUES_EQUAL (c, dconsthalf))
                {
-                 tree sqrtfn;
-
-                 fcode = DECL_FUNCTION_CODE (fndecl);
-                 if (fcode == BUILT_IN_POW)
-                   sqrtfn = implicit_built_in_decls[BUILT_IN_SQRT];
-                 else if (fcode == BUILT_IN_POWF)
-                   sqrtfn = implicit_built_in_decls[BUILT_IN_SQRTF];
-                 else if (fcode == BUILT_IN_POWL)
-                   sqrtfn = implicit_built_in_decls[BUILT_IN_SQRTL];
-                 else
-                   sqrtfn = NULL_TREE;
+                 tree sqrtfn = mathfn_built_in (type, BUILT_IN_SQRT);
 
                  if (sqrtfn != NULL_TREE)
                    {
index 75ef65c1363f4ed1d62c9c65654df1a9c35776a2..d67944a735c4f2d1aa09f9e6d593d1d5ef659328 100644 (file)
@@ -6509,25 +6509,7 @@ fold (tree expr)
                  && operand_equal_p (TREE_VALUE (TREE_OPERAND (arg0, 1)),
                                      TREE_VALUE (TREE_OPERAND (arg1, 1)), 0))
                {
-                 tree sinfn;
-
-                 switch (fcode0)
-                   {
-                   case BUILT_IN_TAN:
-                   case BUILT_IN_COS:
-                     sinfn = implicit_built_in_decls[BUILT_IN_SIN];
-                     break;
-                   case BUILT_IN_TANF:
-                   case BUILT_IN_COSF:
-                     sinfn = implicit_built_in_decls[BUILT_IN_SINF];
-                     break;
-                   case BUILT_IN_TANL:
-                   case BUILT_IN_COSL:
-                     sinfn = implicit_built_in_decls[BUILT_IN_SINL];
-                     break;
-                   default:
-                     sinfn = NULL_TREE;
-                   }
+                 tree sinfn = mathfn_built_in (type, BUILT_IN_SIN);
 
                  if (sinfn != NULL_TREE)
                    return build_function_call_expr (sinfn,
@@ -6588,16 +6570,7 @@ fold (tree expr)
              if (! optimize_size
                  && operand_equal_p (arg0, arg1, 0))
                {
-                 tree powfn;
-
-                 if (type == double_type_node)
-                   powfn = implicit_built_in_decls[BUILT_IN_POW];
-                 else if (type == float_type_node)
-                   powfn = implicit_built_in_decls[BUILT_IN_POWF];
-                 else if (type == long_double_type_node)
-                   powfn = implicit_built_in_decls[BUILT_IN_POWL];
-                 else
-                   powfn = NULL_TREE;
+                 tree powfn = mathfn_built_in (type, BUILT_IN_POW);
 
                  if (powfn)
                    {
@@ -6831,16 +6804,7 @@ fold (tree expr)
              && operand_equal_p (TREE_VALUE (TREE_OPERAND (arg0, 1)),
                                  TREE_VALUE (TREE_OPERAND (arg1, 1)), 0))
            {
-             tree tanfn;
-
-             if (fcode0 == BUILT_IN_SIN)
-               tanfn = implicit_built_in_decls[BUILT_IN_TAN];
-             else if (fcode0 == BUILT_IN_SINF)
-               tanfn = implicit_built_in_decls[BUILT_IN_TANF];
-             else if (fcode0 == BUILT_IN_SINL)
-               tanfn = implicit_built_in_decls[BUILT_IN_TANL];
-             else
-               tanfn = NULL_TREE;
+             tree tanfn = mathfn_built_in (type, BUILT_IN_TAN);
 
              if (tanfn != NULL_TREE)
                return build_function_call_expr (tanfn,
@@ -6854,16 +6818,7 @@ fold (tree expr)
              && operand_equal_p (TREE_VALUE (TREE_OPERAND (arg0, 1)),
                                  TREE_VALUE (TREE_OPERAND (arg1, 1)), 0))
            {
-             tree tanfn;
-
-             if (fcode0 == BUILT_IN_COS)
-               tanfn = implicit_built_in_decls[BUILT_IN_TAN];
-             else if (fcode0 == BUILT_IN_COSF)
-               tanfn = implicit_built_in_decls[BUILT_IN_TANF];
-             else if (fcode0 == BUILT_IN_COSL)
-               tanfn = implicit_built_in_decls[BUILT_IN_TANL];
-             else
-               tanfn = NULL_TREE;
+             tree tanfn = mathfn_built_in (type, BUILT_IN_TAN);
 
              if (tanfn != NULL_TREE)
                {