diff options
Diffstat (limited to 'gcc/tree-switch-conversion.cc')
-rw-r--r-- | gcc/tree-switch-conversion.cc | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc index 50a1792..990f5e1 100644 --- a/gcc/tree-switch-conversion.cc +++ b/gcc/tree-switch-conversion.cc @@ -1782,7 +1782,7 @@ switch_decision_tree::analyze_switch_statement () tree high = CASE_HIGH (elt); profile_probability p - = case_edge->probability.apply_scale (1, (intptr_t) (case_edge->aux)); + = case_edge->probability / ((intptr_t) (case_edge->aux)); clusters.quick_push (new simple_cluster (low, high, elt, case_edge->dest, p)); m_case_bbs.quick_push (case_edge->dest); @@ -2057,7 +2057,7 @@ switch_decision_tree::balance_case_nodes (case_tree_node **head, /* Split this list if it is long enough for that to help. */ npp = head; left = *npp; - profile_probability pivot_prob = prob.apply_scale (1, 2); + profile_probability pivot_prob = prob / 2; /* Find the place in the list that bisects the list's total cost by probability. */ @@ -2259,12 +2259,11 @@ switch_decision_tree::emit_case_nodes (basic_block bb, tree index, redirect_edge_succ (single_pred_edge (test_bb), single_succ_edge (bb)->dest); - p = ((node->m_right->m_c->m_subtree_prob - + default_prob.apply_scale (1, 2)) + p = ((node->m_right->m_c->m_subtree_prob + default_prob / 2) / (node->m_c->m_subtree_prob + default_prob)); bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_high (), GT_EXPR, test_bb, p, loc); - default_prob = default_prob.apply_scale (1, 2); + default_prob /= 2; /* Handle the left-hand subtree. */ bb = emit_case_nodes (bb, index, node->m_left, @@ -2293,11 +2292,11 @@ switch_decision_tree::emit_case_nodes (basic_block bb, tree index, if (node->m_right->has_child () || !node->m_right->m_c->is_single_value_p ()) { - p = (default_prob.apply_scale (1, 2) + p = ((default_prob / 2) / (node->m_c->m_subtree_prob + default_prob)); bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_low (), LT_EXPR, m_default_bb, p, loc); - default_prob = default_prob.apply_scale (1, 2); + default_prob /= 2; bb = emit_case_nodes (bb, index, node->m_right, default_prob, index_type, loc); @@ -2320,11 +2319,11 @@ switch_decision_tree::emit_case_nodes (basic_block bb, tree index, if (node->m_left->has_child () || !node->m_left->m_c->is_single_value_p ()) { - p = (default_prob.apply_scale (1, 2) + p = ((default_prob / 2) / (node->m_c->m_subtree_prob + default_prob)); bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_high (), GT_EXPR, m_default_bb, p, loc); - default_prob = default_prob.apply_scale (1, 2); + default_prob /= 2; bb = emit_case_nodes (bb, index, node->m_left, default_prob, index_type, loc); @@ -2357,29 +2356,29 @@ switch_decision_tree::emit_case_nodes (basic_block bb, tree index, profile_probability right_prob = profile_probability::never (); if (node->m_right) right_prob = node->m_right->m_c->m_subtree_prob; - p = ((right_prob + default_prob.apply_scale (1, 2)) - / (node->m_c->m_subtree_prob + default_prob)); + p = ((right_prob + default_prob / 2) + / (node->m_c->m_subtree_prob + default_prob)); - bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_high (), - GT_EXPR, test_bb, p, loc); - default_prob = default_prob.apply_scale (1, 2); + bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_high (), + GT_EXPR, test_bb, p, loc); + default_prob /= 2; - /* Value belongs to this node or to the left-hand subtree. */ - p = node->m_c->m_prob / (node->m_c->m_subtree_prob + default_prob); - bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_low (), - GE_EXPR, node->m_c->m_case_bb, p, loc); + /* Value belongs to this node or to the left-hand subtree. */ + p = node->m_c->m_prob / (node->m_c->m_subtree_prob + default_prob); + bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_low (), + GE_EXPR, node->m_c->m_case_bb, p, loc); - /* Handle the left-hand subtree. */ - bb = emit_case_nodes (bb, index, node->m_left, - default_prob, index_type, loc); + /* Handle the left-hand subtree. */ + bb = emit_case_nodes (bb, index, node->m_left, default_prob, + index_type, loc); - /* If the left-hand subtree fell through, - don't let it fall into the right-hand subtree. */ - if (bb && m_default_bb) - emit_jump (bb, m_default_bb); + /* If the left-hand subtree fell through, + don't let it fall into the right-hand subtree. */ + if (bb && m_default_bb) + emit_jump (bb, m_default_bb); - bb = emit_case_nodes (test_bb, index, node->m_right, - default_prob, index_type, loc); + bb = emit_case_nodes (test_bb, index, node->m_right, default_prob, + index_type, loc); } else { |