re PR ipa/60243 (IPA is slow on large cgraph tree)
authorRichard Biener <rguenther@suse.de>
Wed, 19 Feb 2014 14:25:47 +0000 (14:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 19 Feb 2014 14:25:47 +0000 (14:25 +0000)
2014-02-19  Richard Biener  <rguenther@suse.de>

PR ipa/60243
* tree-inline.c (estimate_num_insns): Avoid calling cgraph_get_node
for all calls.

From-SVN: r207899

gcc/ChangeLog
gcc/tree-inline.c

index fa67c9e17ff8d33f21e6b0d5cd58b870b37896e1..a71885409b37888cb92b67ae886c565da426c6ce 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-19  Richard Biener  <rguenther@suse.de>
+
+       PR ipa/60243
+       * tree-inline.c (estimate_num_insns): Avoid calling cgraph_get_node
+       for all calls.
+
 2014-02-19  Richard Biener  <rguenther@suse.de>
 
        PR ipa/60243
index 16c0622cf751fcdf74b9110f59fec759c57144ed..fc830977f88326e1f59da1f5104ff704c0475754 100644 (file)
@@ -3824,46 +3824,49 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
     case GIMPLE_CALL:
       {
        tree decl;
-       struct cgraph_node *node = NULL;
 
-       /* Do not special case builtins where we see the body.
-          This just confuse inliner.  */
        if (gimple_call_internal_p (stmt))
          return 0;
-       else if (!(decl = gimple_call_fndecl (stmt))
-                || !(node = cgraph_get_node (decl))
-                || node->definition)
-         ;
-       /* For buitins that are likely expanded to nothing or
-          inlined do not account operand costs.  */
-       else if (is_simple_builtin (decl))
-         return 0;
-       else if (is_inexpensive_builtin (decl))
-         return weights->target_builtin_call_cost;
-       else if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+       else if ((decl = gimple_call_fndecl (stmt))
+                && DECL_BUILT_IN (decl))
          {
-           /* We canonicalize x * x to pow (x, 2.0) with -ffast-math, so
-              specialize the cheap expansion we do here.
-              ???  This asks for a more general solution.  */
-           switch (DECL_FUNCTION_CODE (decl))
+           /* Do not special case builtins where we see the body.
+              This just confuse inliner.  */
+           struct cgraph_node *node;
+           if (!(node = cgraph_get_node (decl))
+               || node->definition)
+             ;
+           /* For buitins that are likely expanded to nothing or
+              inlined do not account operand costs.  */
+           else if (is_simple_builtin (decl))
+             return 0;
+           else if (is_inexpensive_builtin (decl))
+             return weights->target_builtin_call_cost;
+           else if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
              {
-               case BUILT_IN_POW:
-               case BUILT_IN_POWF:
-               case BUILT_IN_POWL:
-                 if (TREE_CODE (gimple_call_arg (stmt, 1)) == REAL_CST
-                     && REAL_VALUES_EQUAL
-                          (TREE_REAL_CST (gimple_call_arg (stmt, 1)), dconst2))
-                   return estimate_operator_cost (MULT_EXPR, weights,
-                                                  gimple_call_arg (stmt, 0),
-                                                  gimple_call_arg (stmt, 0));
-                 break;
-
-               default:
-                 break;
+               /* We canonicalize x * x to pow (x, 2.0) with -ffast-math, so
+                  specialize the cheap expansion we do here.
+                  ???  This asks for a more general solution.  */
+               switch (DECL_FUNCTION_CODE (decl))
+                 {
+                   case BUILT_IN_POW:
+                   case BUILT_IN_POWF:
+                   case BUILT_IN_POWL:
+                     if (TREE_CODE (gimple_call_arg (stmt, 1)) == REAL_CST
+                         && REAL_VALUES_EQUAL
+                         (TREE_REAL_CST (gimple_call_arg (stmt, 1)), dconst2))
+                       return estimate_operator_cost
+                           (MULT_EXPR, weights, gimple_call_arg (stmt, 0),
+                            gimple_call_arg (stmt, 0));
+                     break;
+
+                   default:
+                     break;
+                 }
              }
          }
 
-       cost = node ? weights->call_cost : weights->indirect_call_cost;
+       cost = decl ? weights->call_cost : weights->indirect_call_cost;
        if (gimple_call_lhs (stmt))
          cost += estimate_move_cost (TREE_TYPE (gimple_call_lhs (stmt)));
        for (i = 0; i < gimple_call_num_args (stmt); i++)