[gcc(refs/users/marxin/heads/switch-lowering-fix-profile)] Fix first part of problems.

Martin Liska marxin@gcc.gnu.org
Tue Jan 25 16:00:41 GMT 2022


https://gcc.gnu.org/g:192ac7a1ff2d248e508055a048b7972a485edda2

commit 192ac7a1ff2d248e508055a048b7972a485edda2
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jan 24 15:45:38 2022 +0100

    Fix first part of problems.

Diff:
---
 gcc/tree-switch-conversion.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
index 670397c87e4..7607f5ae019 100644
--- a/gcc/tree-switch-conversion.cc
+++ b/gcc/tree-switch-conversion.cc
@@ -2162,6 +2162,7 @@ switch_decision_tree::emit_cmp_and_jump_insns (basic_block bb, tree op0,
   edge false_edge = split_block (bb, cond);
   false_edge->flags = EDGE_FALSE_VALUE;
   false_edge->probability = prob.invert ();
+  false_edge->dest->count = bb->count.apply_probability (prob.invert ());
 
   edge true_edge = make_edge (bb, label_bb, EDGE_TRUE_VALUE);
   true_edge->probability = prob;
@@ -2192,6 +2193,7 @@ switch_decision_tree::do_jump_if_equal (basic_block bb, tree op0, tree op1,
   edge false_edge = split_block (bb, cond);
   false_edge->flags = EDGE_FALSE_VALUE;
   false_edge->probability = prob.invert ();
+  false_edge->dest->count = bb->count.apply_probability (prob.invert ());
 
   edge true_edge = make_edge (bb, label_bb, EDGE_TRUE_VALUE);
   true_edge->probability = prob;
@@ -2262,6 +2264,7 @@ switch_decision_tree::emit_case_nodes (basic_block bb, tree index,
 	      p = ((node->m_right->m_c->m_subtree_prob
 		    + default_prob.apply_scale (1, 2))
 		   / (node->m_c->m_subtree_prob + default_prob));
+	      test_bb->count = bb->count.apply_probability (p);
 	      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);
@@ -2359,6 +2362,7 @@ switch_decision_tree::emit_case_nodes (basic_block bb, tree index,
 	     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));
+	  test_bb->count = bb->count.apply_probability (p);
 
 	  bb = emit_cmp_and_jump_insns (bb, index, node->m_c->get_high (),
 					GT_EXPR, test_bb, p, loc);


More information about the Gcc-cvs mailing list