diff options
author | Easwaran Raman <eraman@google.com> | 2012-10-16 05:28:08 +0000 |
---|---|---|
committer | Easwaran Raman <eraman@gcc.gnu.org> | 2012-10-16 05:28:08 +0000 |
commit | a4da41e1279cf8bf84fc0a0d4e3af5c5e297c011 (patch) | |
tree | 73e706f18d0cfa88bafa5eb814ff70dbc3d9885c /gcc/optabs.c | |
parent | 07a1164095855c3556b24245e6d89a2f59b626b0 (diff) | |
download | gcc-a4da41e1279cf8bf84fc0a0d4e3af5c5e297c011.zip gcc-a4da41e1279cf8bf84fc0a0d4e3af5c5e297c011.tar.gz gcc-a4da41e1279cf8bf84fc0a0d4e3af5c5e297c011.tar.bz2 |
[multiple changes]
2012-10-15 Easwaran Raman <eraman@google.com>
* optabs.c (emit_cmp_and_jump_insn_1): Add a new parameter to
specificy the probability of taking the jump.
(emit_cmp_and_jump_insns): Likewise.
(expand_compare_and_swap_loop): Make the jump predicted not taken.
* dojump.c (do_compare_rtx_and_jump): Remove the code attaching
REG_BR_PROB note and pass probability to emit_cmp_and_jump_insns.
* cfgbuild.c (compute_outgoing_frequencies): Do not guess outgoing
probabilities for branches with more than two successors.
* expr.c (emit_block_move_via_loop): Predict the loop backedge loop
to be highly taken.
(try_casesi): Pass the probability of jumping to the default label.
(try_tablejump): Likewise.
(do_tablejump): Likewise.
* expr.h (try_tablejump): Add a new parameter.
(try_casesi): Likewise.
(emit_cmp_and_jump_insns): Add probability as default parameter with a
default value of -1.
* except.c (sjlj_emit_function_enter): Pass probability to
emit_cmp_and_jump_insns.
* stmt.c (case_node): Add new fields PROB and SUBTREE_PROB.
(do_jump_if_equal): Pass probability for REG_BR_PROB note.
(add_case_node): Pass estimated probability of jumping to the case
label.
(emit_case_decision_tree): Pass default_prob to emit_case_nodes.
(get_outgoing_edge_probs): New function.
(conditional_probability): Likewise.
(reset_out_edges_aux): Likewise.
(compute_cases_per_edge): Likewise.
(emit_case_dispatch_table): Update probabilities of edges coming out
of the switch statement.
(expand_case): Compute and propagate default edge probability to
emit_case_dispatch_table.
(expand_sjlj_dispatch_table): Update calls to add_case_node and
emit_case_dispatch_table.
(balance_case_nodes): Update subtree_prob values.
(emit_case_nodes): Compute edge probabilities and add pass them to
emit_cmp_and_jump_insns.
testsuite/ChangeLog:
2012-10-15 Easwaran Raman <eraman@google.com>
* gcc.dg/tree-prof/switch-case-1.c: New test case.
* gcc.dg/tree-prof/switch-case-2.c: New test case.
From-SVN: r192488
Diffstat (limited to 'gcc/optabs.c')
-rw-r--r-- | gcc/optabs.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/gcc/optabs.c b/gcc/optabs.c index a63394d..e220316 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -4249,11 +4249,12 @@ prepare_operand (enum insn_code icode, rtx x, int opnum, enum machine_mode mode, we can do the branch. */ static void -emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label) +emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label, int prob) { enum machine_mode optab_mode; enum mode_class mclass; enum insn_code icode; + rtx insn; mclass = GET_MODE_CLASS (mode); optab_mode = (mclass == MODE_CC) ? CCmode : mode; @@ -4261,7 +4262,17 @@ emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label) gcc_assert (icode != CODE_FOR_nothing); gcc_assert (insn_operand_matches (icode, 0, test)); - emit_jump_insn (GEN_FCN (icode) (test, XEXP (test, 0), XEXP (test, 1), label)); + insn = emit_jump_insn (GEN_FCN (icode) (test, XEXP (test, 0), + XEXP (test, 1), label)); + if (prob != -1 + && profile_status != PROFILE_ABSENT + && insn + && JUMP_P (insn) + && any_condjump_p (insn)) + { + gcc_assert (!find_reg_note (insn, REG_BR_PROB, 0)); + add_reg_note (insn, REG_BR_PROB, GEN_INT (prob)); + } } /* Generate code to compare X with Y so that the condition codes are @@ -4279,11 +4290,14 @@ emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label) COMPARISON is the rtl operator to compare with (EQ, NE, GT, etc.). It will be potentially converted into an unsigned variant based on - UNSIGNEDP to select a proper jump instruction. */ + UNSIGNEDP to select a proper jump instruction. + + PROB is the probability of jumping to LABEL. */ void emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size, - enum machine_mode mode, int unsignedp, rtx label) + enum machine_mode mode, int unsignedp, rtx label, + int prob) { rtx op0 = x, op1 = y; rtx test; @@ -4307,7 +4321,7 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size, prepare_cmp_insn (op0, op1, comparison, size, unsignedp, OPTAB_LIB_WIDEN, &test, &mode); - emit_cmp_and_jump_insn_1 (test, mode, label); + emit_cmp_and_jump_insn_1 (test, mode, label, prob); } @@ -6952,9 +6966,9 @@ expand_compare_and_swap_loop (rtx mem, rtx old_reg, rtx new_reg, rtx seq) if (oldval != cmp_reg) emit_move_insn (cmp_reg, oldval); - /* ??? Mark this jump predicted not taken? */ + /* Mark this jump predicted not taken. */ emit_cmp_and_jump_insns (success, const0_rtx, EQ, const0_rtx, - GET_MODE (success), 1, label); + GET_MODE (success), 1, label, 0); return true; } |