aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2008-01-09 20:19:40 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2008-01-09 19:19:40 +0000
commit88743d3a8a58f119524f808d11bb3f7f0d0982e9 (patch)
tree1e0d0defe7e6cc65d0b83210c13086a8e138a25b /gcc
parentd4b7e62e443c269e1c50653a763a61a8ce7cc676 (diff)
downloadgcc-88743d3a8a58f119524f808d11bb3f7f0d0982e9.zip
gcc-88743d3a8a58f119524f808d11bb3f7f0d0982e9.tar.gz
gcc-88743d3a8a58f119524f808d11bb3f7f0d0982e9.tar.bz2
re PR tree-optimization/34708 (Inlining heuristics issue)
PR tree-optimization/34708 * tree-inline.c (estimate_num_insns_1): Compute cost of SWITCH_EXPR based on number of case labels. (init_inline_once): Remove switch_cost. * tree-inline.h (eni_weights_d): Remove switch_cost. From-SVN: r131433
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/tree-inline.c12
-rw-r--r--gcc/tree-inline.h3
3 files changed, 14 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bfdeb65..9f03fe3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-09 Jan Hubicka <jh@suse.cz>
+
+ PR tree-optimization/34708
+ * tree-inline.c (estimate_num_insns_1): Compute cost of SWITCH_EXPR
+ based on number of case labels.
+ (init_inline_once): Remove switch_cost.
+ * tree-inline.h (eni_weights_d): Remove switch_cost.
+
2008-01-09 Richard Guenther <rguenther@suse.de>
Andrew Pinski <andrew_pinski@playstation.sony.com>
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 8c5626d..f825c5d 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2387,9 +2387,12 @@ estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
break;
case SWITCH_EXPR:
- /* TODO: Cost of a switch should be derived from the number of
- branches. */
- d->count += d->weights->switch_cost;
+ /* Take into account cost of the switch + guess 2 conditional jumps for
+ each case label.
+
+ TODO: once the switch expansion logic is sufficiently separated, we can
+ do better job on estimating cost of the switch. */
+ d->count += TREE_VEC_LENGTH (SWITCH_LABELS (x)) * 2;
break;
/* Few special cases of expensive operations. This is useful
@@ -2518,13 +2521,11 @@ init_inline_once (void)
eni_inlining_weights.call_cost = PARAM_VALUE (PARAM_INLINE_CALL_COST);
eni_inlining_weights.target_builtin_call_cost = 1;
eni_inlining_weights.div_mod_cost = 10;
- eni_inlining_weights.switch_cost = 1;
eni_inlining_weights.omp_cost = 40;
eni_size_weights.call_cost = 1;
eni_size_weights.target_builtin_call_cost = 1;
eni_size_weights.div_mod_cost = 1;
- eni_size_weights.switch_cost = 10;
eni_size_weights.omp_cost = 40;
/* Estimating time for call is difficult, since we have no idea what the
@@ -2534,7 +2535,6 @@ init_inline_once (void)
eni_time_weights.call_cost = 10;
eni_time_weights.target_builtin_call_cost = 10;
eni_time_weights.div_mod_cost = 10;
- eni_time_weights.switch_cost = 4;
eni_time_weights.omp_cost = 40;
}
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
index dbb78d0..893b9c9 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -115,9 +115,6 @@ typedef struct eni_weights_d
/* Cost of "expensive" div and mod operations. */
unsigned div_mod_cost;
- /* Cost of switch statement. */
- unsigned switch_cost;
-
/* Cost for omp construct. */
unsigned omp_cost;
} eni_weights;