aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-switch-conversion.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-04-14 11:48:22 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-04-14 11:48:22 +0000
commit727987844249aafe00ffaf7a8030564c1f731607 (patch)
treef84d71d3dd776681297695f30004e73b68bd9c62 /gcc/tree-switch-conversion.c
parentb15b59794635b6d6b3ebdda6bbc7f32d801118f6 (diff)
downloadgcc-727987844249aafe00ffaf7a8030564c1f731607.zip
gcc-727987844249aafe00ffaf7a8030564c1f731607.tar.gz
gcc-727987844249aafe00ffaf7a8030564c1f731607.tar.bz2
tree-switch-conversion.c (lshift_cheap_p): Get speed_p as argument.
2014-04-14 Richard Biener <rguenther@suse.de> * tree-switch-conversion.c (lshift_cheap_p): Get speed_p as argument. (expand_switch_using_bit_tests_p): Likewise. (process_switch): Compute and pass on speed_p based on the switch stmt. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Use optimize_bb_for_speed_p. From-SVN: r209364
Diffstat (limited to 'gcc/tree-switch-conversion.c')
-rw-r--r--gcc/tree-switch-conversion.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 547ac9e..5540ed3 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -130,21 +130,18 @@ hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip,
This function (and similar RTL-related cost code in e.g. IVOPTS) should
be moved to some kind of interface file for GIMPLE/RTL interactions. */
static bool
-lshift_cheap_p (void)
+lshift_cheap_p (bool speed_p)
{
/* FIXME: This should be made target dependent via this "this_target"
mechanism, similar to e.g. can_copy_init_p in gcse.c. */
static bool init[2] = {false, false};
static bool cheap[2] = {true, true};
- bool speed_p;
/* If the targer has no lshift in word_mode, the operation will most
probably not be cheap. ??? Does GCC even work for such targets? */
if (optab_handler (ashl_optab, word_mode) == CODE_FOR_nothing)
return false;
- speed_p = optimize_insn_for_speed_p ();
-
if (!init[speed_p])
{
rtx reg = gen_raw_REG (word_mode, 10000);
@@ -165,12 +162,12 @@ lshift_cheap_p (void)
static bool
expand_switch_using_bit_tests_p (tree range,
unsigned int uniq,
- unsigned int count)
+ unsigned int count, bool speed_p)
{
return (((uniq == 1 && count >= 3)
|| (uniq == 2 && count >= 5)
|| (uniq == 3 && count >= 6))
- && lshift_cheap_p ()
+ && lshift_cheap_p (speed_p)
&& compare_tree_int (range, GET_MODE_BITSIZE (word_mode)) < 0
&& compare_tree_int (range, 0) > 0);
}
@@ -1357,7 +1354,9 @@ process_switch (gimple swtch)
if (info.uniq <= MAX_CASE_BIT_TESTS)
{
if (expand_switch_using_bit_tests_p (info.range_size,
- info.uniq, info.count))
+ info.uniq, info.count,
+ optimize_bb_for_speed_p
+ (gimple_bb (swtch))))
{
if (dump_file)
fputs (" expanding as bit test is preferable\n", dump_file);