This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] Generic estimate_num_insns


Hi,
this patch replaces language specific code to estimate_num_insns by
generic one.
Bootstrapped tree-ssa with the patch to enable unit-at-a-time.  OK?

Wed Oct 22 00:03:23 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* c-common.c (c_estimate_num_insns_1): Kill.
	(c_estimate_num_insns): Kill.
	* c-common.h (c_estimate_num_insns): Kill.
	* c-lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Kill.
	* cp-lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Kill.
	* objc-lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Kill.
	* lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Kill.
	(java_estimate_num_insns_1, java_estimate_num_insns): Kill.
	* cgraphunit (cgraph_analyze_function): Use estimate_num_insns.
	* tree-eh.c (decide_copy_try_finally): Likewise.
	* tree-inline.c (limits_allow_inilining, optimize_inline_calls): Likewise.
	(estimate_num_insns_1, estimate_num_insns): New functions.
	* langhooks-def.h (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Kill.
	* langhooks.h (estimate_num_inssn): Kill.
	* tree-inline.h (estimate_num_insns): Declare.
diff -rc3p gcc.old/c-common.c gcc/c-common.c
*** gcc.old/c-common.c	Tue Oct 21 23:19:23 2003
--- gcc/c-common.c	Tue Oct 21 23:44:20 2003
*************** resort_sorted_fields (void *obj,
*** 5775,5888 ****
           resort_field_decl_cmp);
  }
  
- /* Used by estimate_num_insns.  Estimate number of instructions seen
-    by given statement.  */
- static tree
- c_estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
- {
-   int *count = data;
-   tree x = *tp;
- 
-   if (TYPE_P (x) || DECL_P (x))
-     {
-       *walk_subtrees = 0;
-       return NULL;
-     }
-   /* Assume that constants and references counts nothing.  These should
-      be majorized by amount of operations among them we count later
-      and are common target of CSE and similar optimizations.  */
-   if (TREE_CODE_CLASS (TREE_CODE (x)) == 'c'
-       || TREE_CODE_CLASS (TREE_CODE (x)) == 'r')
-     return NULL;
-   switch (TREE_CODE (x))
-     { 
-     /* Reconginze assignments of large structures and constructors of
-        big arrays.  */
-     case MODIFY_EXPR:
-     case CONSTRUCTOR:
-       {
- 	int size = int_size_in_bytes (TREE_TYPE (x));
- 
- 	if (!size || size > MOVE_MAX_PIECES)
- 	  *count += 10;
- 	else
- 	  *count += 2 * (size + MOVE_MAX - 1) / MOVE_MAX;
- 	return NULL;
-       }
-       break;
-     /* Few special cases of expensive operations.  This is usefull
-        to avoid inlining on functions having too many of these.  */
-     case TRUNC_DIV_EXPR:
-     case CEIL_DIV_EXPR:
-     case FLOOR_DIV_EXPR:
-     case ROUND_DIV_EXPR:
-     case TRUNC_MOD_EXPR:
-     case CEIL_MOD_EXPR:
-     case FLOOR_MOD_EXPR:
-     case ROUND_MOD_EXPR:
-     case RDIV_EXPR:
-     case CALL_EXPR:
-       *count += 10;
-       break;
-     /* Various containers that will produce no code themselves.  */
-     case INIT_EXPR:
-     case TARGET_EXPR:
-     case BIND_EXPR:
-     case BLOCK:
-     case TREE_LIST:
-     case TREE_VEC:
-     case IDENTIFIER_NODE:
-     case PLACEHOLDER_EXPR:
-     case WITH_CLEANUP_EXPR:
-     case CLEANUP_POINT_EXPR:
-     case NOP_EXPR:
-     case VIEW_CONVERT_EXPR:
-     case SAVE_EXPR:
-     case UNSAVE_EXPR:
-     case COMPLEX_EXPR:
-     case REALPART_EXPR:
-     case IMAGPART_EXPR:
-     case TRY_CATCH_EXPR:
-     case TRY_FINALLY_EXPR:
-     case LABEL_EXPR:
-     case EXIT_EXPR:
-     case LABELED_BLOCK_EXPR:
-     case EXIT_BLOCK_EXPR:
- 
-     case EXPR_STMT:
-     case COMPOUND_STMT:
-     case RETURN_STMT:
-     case LABEL_STMT:
-     case SCOPE_STMT:
-     case FILE_STMT:
-     case CASE_LABEL:
-     case STMT_EXPR:
-     case CLEANUP_STMT:
- 
-     case SIZEOF_EXPR:
-     case ARROW_EXPR:
-     case ALIGNOF_EXPR:
-       break;
-     case DECL_STMT:
-       /* Do not account static initializers.  */
-       if (TREE_STATIC (TREE_OPERAND (x, 0)))
- 	*walk_subtrees = 0;
-       break;
-     default:
-       (*count)++;
-     }
-   return NULL;
- }
- 
- /* Estimate number of instructions that will be created by expanding EXPR.  */
- int
- c_estimate_num_insns (tree expr)
- {
-   int num = 0;
-   walk_tree_without_duplicates (&expr, c_estimate_num_insns_1, &num);
-   return num;
- }
- 
  /* Used by c_decl_uninit to find where expressions like x = x + 1; */
  
  static tree
--- 5775,5780 ----
diff -rc3p gcc.old/c-common.h gcc/c-common.h
*** gcc.old/c-common.h	Tue Oct 21 23:19:23 2003
--- gcc/c-common.h	Tue Oct 21 23:44:37 2003
*************** extern void c_common_no_more_pch (void);
*** 1299,1305 ****
  extern void builtin_define_with_value (const char *, const char *, int);
  extern void c_stddef_cpp_builtins (void);
  extern void fe_file_change (const struct line_map *);
- extern int c_estimate_num_insns (tree decl);
  extern bool c_decl_uninit (tree t);
  
  /* The following have been moved here from c-tree.h, since they're needed
--- 1299,1304 ----
diff -rc3p gcc.old/c-lang.c gcc/c-lang.c
*** gcc.old/c-lang.c	Tue Oct 21 23:19:42 2003
--- gcc/c-lang.c	Tue Oct 21 23:44:30 2003
*************** enum c_language_kind c_language = clk_c;
*** 120,127 ****
  #undef LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING
  #define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
    c_convert_parm_for_inlining
- #undef LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS
- #define LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS c_estimate_num_insns
  #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
  #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN c_dump_tree
  
--- 120,125 ----
diff -rc3p gcc.old/cgraphunit.c gcc/cgraphunit.c
*** gcc.old/cgraphunit.c	Tue Oct 21 23:19:22 2003
--- gcc/cgraphunit.c	Tue Oct 21 23:43:34 2003
*************** cgraph_analyze_function (struct cgraph_n
*** 315,322 ****
  
    node->local.inlinable = tree_inlinable_function_p (decl);
    if (!DECL_ESTIMATED_INSNS (decl))
!     DECL_ESTIMATED_INSNS (decl)
!       = (*lang_hooks.tree_inlining.estimate_num_insns) (DECL_SAVED_TREE (decl));
    node->local.self_insns = DECL_ESTIMATED_INSNS (decl);
    if (node->local.inlinable)
      node->local.disregard_inline_limits
--- 315,321 ----
  
    node->local.inlinable = tree_inlinable_function_p (decl);
    if (!DECL_ESTIMATED_INSNS (decl))
!     DECL_ESTIMATED_INSNS (decl) = estimate_num_insns (DECL_SAVED_TREE (decl));
    node->local.self_insns = DECL_ESTIMATED_INSNS (decl);
    if (node->local.inlinable)
      node->local.disregard_inline_limits
diff -rc3p gcc.old/cp/cp-lang.c gcc/cp/cp-lang.c
*** gcc.old/cp/cp-lang.c	Tue Oct 21 23:19:00 2003
--- gcc/cp/cp-lang.c	Tue Oct 21 23:44:52 2003
*************** static void cxx_initialize_diagnostics (
*** 161,168 ****
  #define LANG_HOOKS_TREE_INLINING_START_INLINING cp_start_inlining
  #undef LANG_HOOKS_TREE_INLINING_END_INLINING
  #define LANG_HOOKS_TREE_INLINING_END_INLINING cp_end_inlining
- #undef LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS
- #define LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS c_estimate_num_insns
  #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
  #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree
  #undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
--- 161,166 ----
diff -rc3p gcc.old/java/lang.c gcc/java/lang.c
*** gcc.old/java/lang.c	Tue Oct 21 23:19:21 2003
--- gcc/java/lang.c	Tue Oct 21 23:45:13 2003
*************** static bool java_can_use_bit_fields_p (v
*** 64,70 ****
  static bool java_dump_tree (void *, tree);
  static void dump_compound_expr (dump_info_p, tree);
  static bool java_decl_ok_for_sibcall (tree);
- static int java_estimate_num_insns (tree);
  static int java_start_inlining (tree);
  
  #ifndef TARGET_OBJECT_SUFFIX
--- 64,69 ----
*************** struct language_function GTY(())
*** 247,255 ****
  #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
  #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE java_signed_or_unsigned_type
  
- #undef LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS
- #define LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS java_estimate_num_insns
- 
  #undef LANG_HOOKS_TREE_INLINING_START_INLINING
  #define LANG_HOOKS_TREE_INLINING_START_INLINING java_start_inlining
  
--- 246,251 ----
*************** java_decl_ok_for_sibcall (tree decl)
*** 1046,1153 ****
    return decl != NULL && DECL_CONTEXT (decl) == current_class;
  }
  
- /* Used by estimate_num_insns.  Estimate number of instructions seen
-    by given statement.  */
- static tree
- java_estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
- {
-   int *count = data;
-   tree x = *tp;
- 
-   if (TYPE_P (x) || DECL_P (x))
-     {
-       *walk_subtrees = 0;
-       return NULL;
-     }
-   /* Assume that constants and references counts nothing.  These should
-      be majorized by amount of operations amoung them we count later
-      and are common target of CSE and similar optimizations.  */
-   if (TREE_CODE_CLASS (TREE_CODE (x)) == 'c'
-       || TREE_CODE_CLASS (TREE_CODE (x)) == 'r')
-     return NULL;
-   switch (TREE_CODE (x))
-     { 
-     /* Reconginze assignments of large structures and constructors of
-        big arrays.  */
-     case MODIFY_EXPR:
-     case CONSTRUCTOR:
-       {
- 	int size = int_size_in_bytes (TREE_TYPE (x));
- 
- 	if (!size || size > MOVE_MAX_PIECES)
- 	  *count += 10;
- 	else
- 	  *count += 2 * (size + MOVE_MAX - 1) / MOVE_MAX;
- 	return NULL;
-       }
-       break;
-     /* Few special cases of expensive operations.  This is usefull
-        to avoid inlining on functions having too many of these.  */
-     case TRUNC_DIV_EXPR:
-     case CEIL_DIV_EXPR:
-     case FLOOR_DIV_EXPR:
-     case ROUND_DIV_EXPR:
-     case TRUNC_MOD_EXPR:
-     case CEIL_MOD_EXPR:
-     case FLOOR_MOD_EXPR:
-     case ROUND_MOD_EXPR:
-     case RDIV_EXPR:
-     case CALL_EXPR:
- 
-     case NEW_ARRAY_EXPR:
-     case NEW_ANONYMOUS_ARRAY_EXPR:
-     case NEW_CLASS_EXPR:
-       *count += 10;
-       break;
-     /* Various containers that will produce no code themselves.  */
-     case INIT_EXPR:
-     case TARGET_EXPR:
-     case BIND_EXPR:
-     case BLOCK:
-     case TREE_LIST:
-     case TREE_VEC:
-     case IDENTIFIER_NODE:
-     case PLACEHOLDER_EXPR:
-     case WITH_CLEANUP_EXPR:
-     case CLEANUP_POINT_EXPR:
-     case NOP_EXPR:
-     case VIEW_CONVERT_EXPR:
-     case SAVE_EXPR:
-     case UNSAVE_EXPR:
-     case COMPLEX_EXPR:
-     case REALPART_EXPR:
-     case IMAGPART_EXPR:
-     case TRY_CATCH_EXPR:
-     case TRY_FINALLY_EXPR:
-     case LABEL_EXPR:
-     case EXIT_EXPR:
-     case LABELED_BLOCK_EXPR:
-     case EXIT_BLOCK_EXPR:
-     case EXPR_WITH_FILE_LOCATION:
-     case UNARY_PLUS_EXPR:
-     case THIS_EXPR:
-     case DEFAULT_EXPR:
-     case TRY_EXPR:
- 
-       break;
-     case CLASS_LITERAL:
-       *walk_subtrees = 0;
-       break;
-     default:
-       (*count)++;
-     }
-   return NULL;
- }
- 
- /*  Estimate number of instructions that will be created by expanding EXPR.  */
- static int
- java_estimate_num_insns (tree expr)
- {
-   int num = 0;
-   walk_tree_without_duplicates (&expr, java_estimate_num_insns_1, &num);
-   return num;
- }
- 
  /* Start inlining fn.  Called by the tree inliner via
     lang_hooks.tree_inlining.cannot_inline_tree_fn.  */
  
--- 1042,1047 ----
diff -rc3p gcc.old/langhooks-def.h gcc/langhooks-def.h
*** gcc.old/langhooks-def.h	Tue Oct 21 23:19:23 2003
--- gcc/langhooks-def.h	Tue Oct 21 23:44:03 2003
*************** int lhd_gimplify_expr (tree *, tree *, t
*** 168,175 ****
    lhd_tree_inlining_end_inlining
  #define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
    lhd_tree_inlining_convert_parm_for_inlining
- #define LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS \
-   NULL
  
  #define LANG_HOOKS_TREE_INLINING_INITIALIZER { \
    LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \
--- 168,173 ----
*************** int lhd_gimplify_expr (tree *, tree *, t
*** 184,190 ****
    LANG_HOOKS_TREE_INLINING_START_INLINING, \
    LANG_HOOKS_TREE_INLINING_END_INLINING, \
    LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING, \
-   LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS \
  }
  
  #define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR lhd_callgraph_analyze_expr
--- 182,187 ----
diff -rc3p gcc.old/langhooks.h gcc/langhooks.h
*** gcc.old/langhooks.h	Tue Oct 21 23:19:23 2003
--- gcc/langhooks.h	Tue Oct 21 23:43:55 2003
*************** struct lang_hooks_for_tree_inlining
*** 48,54 ****
    int (*start_inlining) (tree);
    void (*end_inlining) (tree);
    tree (*convert_parm_for_inlining) (tree, tree, tree);
-   int (*estimate_num_insns) (tree);
  };
  
  struct lang_hooks_for_callgraph
--- 48,53 ----
diff -rc3p gcc.old/objc/objc-lang.c gcc/objc/objc-lang.c
*** gcc.old/objc/objc-lang.c	Tue Oct 21 23:19:22 2003
--- gcc/objc/objc-lang.c	Tue Oct 21 23:44:46 2003
*************** enum c_language_kind c_language = clk_ob
*** 114,121 ****
  #undef LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P
  #define LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P \
    c_tree_chain_matters_p
- #undef LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS
- #define LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS c_estimate_num_insns
  
  #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
  #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION c_expand_body
--- 114,119 ----
diff -rc3p gcc.old/tree-eh.c gcc/tree-eh.c
*** gcc.old/tree-eh.c	Tue Oct 21 23:19:35 2003
--- gcc/tree-eh.c	Tue Oct 21 23:47:09 2003
*************** decide_copy_try_finally (int ndests, tre
*** 1187,1193 ****
      return false;
  
    /* Finally estimate N times, plus N gotos.  */
!   f_estimate = (*lang_hooks.tree_inlining.estimate_num_insns) (finally);
    f_estimate = (f_estimate + 1) * ndests;
  
    /* Switch statement (cost 10), N variable assignments, N gotos.  */
--- 1187,1193 ----
      return false;
  
    /* Finally estimate N times, plus N gotos.  */
!   f_estimate = estimate_num_insns (finally);
    f_estimate = (f_estimate + 1) * ndests;
  
    /* Switch statement (cost 10), N variable assignments, N gotos.  */
diff -rc3p gcc.old/tree-inline.c gcc/tree-inline.c
*** gcc.old/tree-inline.c	Tue Oct 21 23:19:22 2003
--- gcc/tree-inline.c	Tue Oct 21 23:53:08 2003
*************** inlinable_function_p (tree fn)
*** 1095,1100 ****
--- 1095,1298 ----
    return inlinable;
  }
  
+ /* Used by estimate_num_insns.  Estimate number of instructions seen
+    by given statement.  */
+ static tree
+ estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
+ {
+   int *count = data;
+   tree x = *tp;
+ 
+   if (TYPE_P (x) || DECL_P (x))
+     {
+       *walk_subtrees = 0;
+       return NULL;
+     }
+   /* Assume that constants and references counts nothing.  These should
+      be majorized by amount of operations among them we count later
+      and are common target of CSE and similar optimizations.  */
+   if (TREE_CODE_CLASS (TREE_CODE (x)) == 'c'
+       || TREE_CODE_CLASS (TREE_CODE (x)) == 'r')
+     return NULL;
+   switch (TREE_CODE (x))
+     { 
+     /* Containers have no cost.  */
+     case TREE_LIST:
+     case TREE_VEC:
+     case BLOCK:
+     case COMPONENT_REF:
+     case BIT_FIELD_REF:
+     case INDIRECT_REF:
+     case BUFFER_REF:
+     case ARRAY_REF:
+     case ARRAY_RANGE_REF:
+     case VTABLE_REF:
+     case EXC_PTR_EXPR: /* ??? */
+     case FILTER_EXPR: /* ??? */
+     case COMPOUND_EXPR:
+     case BIND_EXPR:
+     case LABELED_BLOCK_EXPR:
+     case WITH_CLEANUP_EXPR:
+     case WITH_RECORD_EXPR:
+     case NOP_EXPR:
+     case VIEW_CONVERT_EXPR:
+     case SAVE_EXPR:
+     case UNSAVE_EXPR:
+     case ADDR_EXPR:
+     case REFERENCE_EXPR:
+     case COMPLEX_EXPR:
+     case REALPART_EXPR:
+     case IMAGPART_EXPR:
+     case EXIT_BLOCK_EXPR:
+     case CASE_LABEL_EXPR:
+     case SSA_NAME:
+     case CATCH_EXPR:
+     case EH_FILTER_EXPR:
+       break;
+     /* We don't account constants for now.  Assume that the cost is amortized
+        by operations that do use them.  We may re-consider this decision once
+        we are able to optimize the tree before estimating it's size and break
+        out static initializers.  */
+     case IDENTIFIER_NODE:
+     case INTEGER_CST:
+     case REAL_CST:
+     case COMPLEX_CST:
+     case VECTOR_CST:
+     case STRING_CST:
+     case ENTRY_VALUE_EXPR:
+     case FDESC_EXPR:
+     case VA_ARG_EXPR:
+     case TRY_CATCH_EXPR:
+     case TRY_FINALLY_EXPR:
+     case LABEL_EXPR:
+     case GOTO_EXPR:
+     case RETURN_EXPR:
+     case EXIT_EXPR:
+     case LOOP_EXPR:
+     case VDEF_EXPR:
+     case EUSE_NODE:
+     case ELEFT_NODE:
+     case EKILL_NODE:
+     case EPHI_NODE:
+     case EEXIT_NODE:
+     case PHI_NODE:
+       *walk_subtrees = 0;
+       return NULL;
+       break;
+     /* Reconginze assignments of large structures and constructors of
+        big arrays.  */
+     case INIT_EXPR:
+     case TARGET_EXPR:
+     case MODIFY_EXPR:
+     case CONSTRUCTOR:
+       {
+ 	int size = int_size_in_bytes (TREE_TYPE (x));
+ 
+ 	if (!size || size > MOVE_MAX_PIECES)
+ 	  *count += 10;
+ 	else
+ 	  *count += 2 * (size + MOVE_MAX - 1) / MOVE_MAX;
+ 	return NULL;
+       }
+       break;
+ 
+       /* Assign cost of 1 to usual operations.
+ 	 ??? We may consider mapping RTL costs to this.  */
+     case COND_EXPR:
+ 
+     case PLUS_EXPR:
+     case MINUS_EXPR:
+     case MULT_EXPR:
+ 
+     case FIX_TRUNC_EXPR:
+     case FIX_CEIL_EXPR:
+     case FIX_FLOOR_EXPR:
+     case FIX_ROUND_EXPR:
+ 
+     case NEGATE_EXPR:
+     case FLOAT_EXPR:
+     case MIN_EXPR:
+     case MAX_EXPR:
+     case ABS_EXPR:
+ 
+     case LSHIFT_EXPR:
+     case RSHIFT_EXPR:
+     case LROTATE_EXPR:
+     case RROTATE_EXPR:
+ 
+     case BIT_IOR_EXPR:
+     case BIT_XOR_EXPR:
+     case BIT_AND_EXPR:
+     case BIT_NOT_EXPR:
+ 
+     case TRUTH_ANDIF_EXPR:
+     case TRUTH_ORIF_EXPR:
+     case TRUTH_AND_EXPR:
+     case TRUTH_OR_EXPR:
+     case TRUTH_XOR_EXPR:
+     case TRUTH_NOT_EXPR:
+ 
+     case LT_EXPR:
+     case LE_EXPR:
+     case GT_EXPR:
+     case GE_EXPR:
+     case EQ_EXPR:
+     case NE_EXPR:
+     case ORDERED_EXPR:
+     case UNORDERED_EXPR:
+ 
+     case UNLT_EXPR:
+     case UNLE_EXPR:
+     case UNGT_EXPR:
+     case UNGE_EXPR:
+     case UNEQ_EXPR:
+ 
+     case CONVERT_EXPR:
+ 
+     case CONJ_EXPR:
+ 
+     case PREDECREMENT_EXPR:
+     case PREINCREMENT_EXPR:
+     case POSTDECREMENT_EXPR:
+     case POSTINCREMENT_EXPR:
+ 
+     case SWITCH_EXPR:
+ 
+     case ASM_EXPR:
+       *count++;
+       break;
+ 
+     /* Few special cases of expensive operations.  This is usefull
+        to avoid inlining on functions having too many of these.  */
+     case TRUNC_DIV_EXPR:
+     case CEIL_DIV_EXPR:
+     case FLOOR_DIV_EXPR:
+     case ROUND_DIV_EXPR:
+     case EXACT_DIV_EXPR:
+     case TRUNC_MOD_EXPR:
+     case CEIL_MOD_EXPR:
+     case FLOOR_MOD_EXPR:
+     case ROUND_MOD_EXPR:
+     case RDIV_EXPR:
+     case CALL_EXPR:
+     case RESX_EXPR:
+       *count += 10;
+       break;
+     default:
+       break;
+     }
+   return NULL;
+ }
+ 
+ /* Estimate number of instructions that will be created by expanding EXPR.  */
+ int
+ estimate_num_insns (tree expr)
+ {
+   int num = 0;
+   walk_tree_without_duplicates (&expr, estimate_num_insns_1, &num);
+   return num;
+ }
+ 
  /* We can't inline functions that are too big.  Only allow a single
     function to be of MAX_INLINE_INSNS_SINGLE size.  Make special
     allowance for extern inline functions, though.
*************** limits_allow_inlining (tree fn, inline_d
*** 1121,1129 ****
        /* If we haven't already done so, get an estimate of the number of
  	 instructions that will be produces when expanding this function.  */
        if (!DECL_ESTIMATED_INSNS (fn))
! 	DECL_ESTIMATED_INSNS (fn)
! 	  = (*lang_hooks.tree_inlining.estimate_num_insns)
! 	    (DECL_SAVED_TREE (fn));
        estimated_insns = DECL_ESTIMATED_INSNS (fn);
  
        /* We may be here either because fn is declared inline or because
--- 1319,1325 ----
        /* If we haven't already done so, get an estimate of the number of
  	 instructions that will be produces when expanding this function.  */
        if (!DECL_ESTIMATED_INSNS (fn))
! 	DECL_ESTIMATED_INSNS (fn) = estimate_num_insns (DECL_SAVED_TREE (fn));
        estimated_insns = DECL_ESTIMATED_INSNS (fn);
  
        /* We may be here either because fn is declared inline or because
*************** optimize_inline_calls (tree fn)
*** 1626,1633 ****
    VARRAY_TREE_INIT (id.fns, 32, "fns");
    VARRAY_PUSH_TREE (id.fns, fn);
    if (!DECL_ESTIMATED_INSNS (fn))
!     DECL_ESTIMATED_INSNS (fn) 
!       = (*lang_hooks.tree_inlining.estimate_num_insns) (fn);
    /* Or any functions that aren't finished yet.  */
    prev_fn = NULL_TREE;
    if (current_function_decl)
--- 1822,1828 ----
    VARRAY_TREE_INIT (id.fns, 32, "fns");
    VARRAY_PUSH_TREE (id.fns, fn);
    if (!DECL_ESTIMATED_INSNS (fn))
!     DECL_ESTIMATED_INSNS (fn) = estimate_num_insns (fn);
    /* Or any functions that aren't finished yet.  */
    prev_fn = NULL_TREE;
    if (current_function_decl)
diff -rc3p gcc.old/tree-inline.h gcc/tree-inline.h
*** gcc.old/tree-inline.h	Tue Oct 21 23:19:22 2003
--- gcc/tree-inline.h	Tue Oct 21 23:43:19 2003
*************** tree walk_tree_without_duplicates (tree*
*** 31,36 ****
--- 31,37 ----
  tree copy_tree_r (tree*, int*, void*);
  void clone_body (tree, tree, void*);
  void remap_save_expr (tree*, void*, tree, int*);
+ int estimate_num_insns (tree expr);
  
  /* 0 if we should not perform inlining.
     1 if we should expand functions calls inline at the tree level.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]