aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/sh
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2017-07-16 18:10:58 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2017-07-16 16:10:58 +0000
commit5fa396ad6cd48bc44e6754096fe71febc2a77983 (patch)
tree8b2c0f4ba184b9d1af37e1f345be3b518d3f6101 /gcc/config/sh
parent519087cf749bd002784f09f0ca6f74215fbf5bbc (diff)
downloadgcc-5fa396ad6cd48bc44e6754096fe71febc2a77983.zip
gcc-5fa396ad6cd48bc44e6754096fe71febc2a77983.tar.gz
gcc-5fa396ad6cd48bc44e6754096fe71febc2a77983.tar.bz2
profile-count.h (profile_probability::from_reg_br_prob_note, [...]): New functions.
* profile-count.h (profile_probability::from_reg_br_prob_note, profile_probability::to_reg_br_prob_note): New functions. * doc/rtl.texi (REG_BR_PROB_NOTE): Update documentation. * reg-notes.h (REG_BR_PROB, REG_BR_PRED): Update docs. * predict.c (probability_reliable_p): Update. (edge_probability_reliable_p): Update. (br_prob_note_reliable_p): Update. (invert_br_probabilities): Update. (add_reg_br_prob_note): New function. (combine_predictions_for_insn): Update. * asan.c (asan_clear_shadow): Update. * cfgbuild.c (compute_outgoing_frequencies): Update. * cfgrtl.c (force_nonfallthru_and_redirect): Update. (update_br_prob_note): Update. (rtl_verify_edges): Update. (purge_dead_edges): Update. (fixup_reorder_chain): Update. * emit-rtl.c (try_split): Update. * ifcvt.c (cond_exec_process_insns): Update. (cond_exec_process_if_block): Update. (dead_or_predicable): Update. * internal-fn.c (expand_addsub_overflow): Update. (expand_neg_overflow): Update. (expand_mul_overflow): Update. * loop-doloop.c (doloop_modify): Update. * loop-unroll.c (compare_and_jump_seq): Update. * optabs.c (emit_cmp_and_jump_insn_1): Update. * predict.h: Update. * reorg.c (mostly_true_jump): Update. * rtl.h: Update. * config/aarch64/aarch64.c (aarch64_emit_unlikely_jump): Update. * config/alpha/alpha.c (emit_unlikely_jump): Update. * config/arc/arc.c: (emit_unlikely_jump): Update. * config/arm/arm.c: (emit_unlikely_jump): Update. * config/bfin/bfin.c (cbranch_predicted_taken_p): Update. * config/frv/frv.c (frv_print_operand_jump_hint): Update. * config/i386/i386.c (ix86_expand_split_stack_prologue): Update. (ix86_print_operand): Update. (ix86_split_fp_branch): Update. (predict_jump): Update. * config/ia64/ia64.c (ia64_print_operand): Update. * config/mmix/mmix.c (mmix_print_operand): Update. * config/powerpcspe/powerpcspe.c (output_cbranch): Update. (rs6000_expand_split_stack_prologue): Update. * config/rs6000/rs6000.c: Update. * config/s390/s390.c (s390_expand_vec_strlen): Update. (s390_expand_vec_movstr): Update. (s390_expand_cs_tdsi): Update. (s390_expand_split_stack_prologue): Update. * config/sh/sh.c (sh_print_operand): Update. (expand_cbranchsi4): Update. (expand_cbranchdi4): Update. * config/sparc/sparc.c (output_v9branch): Update. * config/spu/spu.c (get_branch_target): Update. (ea_load_store_inline): Update. * config/tilegx/tilegx.c (cbranch_predicted_p): Update. * config/tilepro/tilepro.c: Update. * gcc.dg/predict-8.c: Update. From-SVN: r250239
Diffstat (limited to 'gcc/config/sh')
-rw-r--r--gcc/config/sh/sh-protos.h2
-rw-r--r--gcc/config/sh/sh.c66
-rw-r--r--gcc/config/sh/sh.md2
3 files changed, 39 insertions, 31 deletions
diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h
index 59be4c0..305ab2c 100644
--- a/gcc/config/sh/sh-protos.h
+++ b/gcc/config/sh/sh-protos.h
@@ -68,7 +68,7 @@ extern bool sh_expand_strlen (rtx *);
extern void sh_expand_setmem (rtx *);
extern enum rtx_code prepare_cbranch_operands (rtx *, machine_mode mode,
enum rtx_code comparison);
-extern void expand_cbranchsi4 (rtx *operands, enum rtx_code comparison, int);
+extern void expand_cbranchsi4 (rtx *operands, enum rtx_code comparison);
extern bool expand_cbranchdi4 (rtx *operands, enum rtx_code comparison);
extern void sh_emit_scc_to_t (enum rtx_code, rtx, rtx);
extern void sh_emit_compare_and_branch (rtx *, machine_mode);
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index ff79b93..6f01dcb 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -1139,7 +1139,9 @@ sh_print_operand (FILE *stream, rtx x, int code)
{
rtx note = find_reg_note (current_output_insn, REG_BR_PROB, 0);
- if (note && XINT (note, 0) * 2 < REG_BR_PROB_BASE)
+ if (note
+ && profile_probability::from_reg_br_prob_note (XINT (note, 0))
+ < profile_probability::even ())
fputs ("/u", stream);
break;
}
@@ -1999,8 +2001,9 @@ prepare_cbranch_operands (rtx *operands, machine_mode mode,
return comparison;
}
-void
-expand_cbranchsi4 (rtx *operands, enum rtx_code comparison, int probability)
+static void
+expand_cbranchsi4 (rtx *operands, enum rtx_code comparison,
+ profile_probability probability)
{
rtx (*branch_expander) (rtx) = gen_branch_true;
comparison = prepare_cbranch_operands (operands, SImode, comparison);
@@ -2015,8 +2018,15 @@ expand_cbranchsi4 (rtx *operands, enum rtx_code comparison, int probability)
gen_rtx_fmt_ee (comparison, SImode,
operands[1], operands[2])));
rtx_insn *jump = emit_jump_insn (branch_expander (operands[3]));
- if (probability >= 0)
- add_int_reg_note (jump, REG_BR_PROB, probability);
+ if (probability.initialized_p ())
+ add_reg_br_prob_note (jump, probability);
+}
+
+void
+expand_cbranchsi4 (rtx *operands, enum rtx_code comparison)
+{
+ expand_cbranchsi4 (operands, comparison,
+ profile_probability::uninitialized ());
}
/* ??? How should we distribute probabilities when more than one branch
@@ -2043,8 +2053,10 @@ expand_cbranchdi4 (rtx *operands, enum rtx_code comparison)
rtx_code_label *skip_label = NULL;
rtx op1h, op1l, op2h, op2l;
int num_branches;
- int prob, rev_prob;
- int msw_taken_prob = -1, msw_skip_prob = -1, lsw_taken_prob = -1;
+ profile_probability prob, rev_prob;
+ profile_probability msw_taken_prob = profile_probability::uninitialized (),
+ msw_skip_prob = profile_probability::uninitialized (),
+ lsw_taken_prob = profile_probability::uninitialized ();
comparison = prepare_cbranch_operands (operands, DImode, comparison);
op1h = gen_highpart_mode (SImode, DImode, operands[1]);
@@ -2053,34 +2065,28 @@ expand_cbranchdi4 (rtx *operands, enum rtx_code comparison)
op2l = gen_lowpart (SImode, operands[2]);
msw_taken = msw_skip = lsw_taken = LAST_AND_UNUSED_RTX_CODE;
prob = split_branch_probability;
- rev_prob = REG_BR_PROB_BASE - prob;
+ rev_prob = prob.invert ();
switch (comparison)
{
case EQ:
msw_skip = NE;
lsw_taken = EQ;
- if (prob >= 0)
+ if (prob.initialized_p ())
{
- // If we had more precision, we'd use rev_prob - (rev_prob >> 32) .
+ /* FIXME: This is not optimal. We do not really know the probablity
+ that values differ by MCW only, but we should probably distribute
+ probabilities more evenly. */
msw_skip_prob = rev_prob;
- if (REG_BR_PROB_BASE <= 65535)
- lsw_taken_prob = prob ? REG_BR_PROB_BASE : 0;
- else
- {
- lsw_taken_prob
- = (prob
- ? (REG_BR_PROB_BASE
- - ((gcov_type) REG_BR_PROB_BASE * rev_prob
- / ((gcov_type) prob << 32)))
- : 0);
- }
+ lsw_taken_prob = prob > profile_probability::never ()
+ ? profile_probability::guessed_always ()
+ : profile_probability::guessed_never ();
}
break;
case NE:
msw_taken = NE;
msw_taken_prob = prob;
lsw_taken = NE;
- lsw_taken_prob = 0;
+ lsw_taken_prob = profile_probability::guessed_never ();
break;
case GTU: case GT:
msw_taken = comparison;
@@ -2133,18 +2139,20 @@ expand_cbranchdi4 (rtx *operands, enum rtx_code comparison)
if (comparison != EQ && comparison != NE && num_branches > 1)
{
if (!CONSTANT_P (operands[2])
- && prob >= (int) (REG_BR_PROB_BASE * 3 / 8U)
- && prob <= (int) (REG_BR_PROB_BASE * 5 / 8U))
- {
- msw_taken_prob = prob / 2U;
- msw_skip_prob
- = REG_BR_PROB_BASE * rev_prob / (REG_BR_PROB_BASE + rev_prob);
+ && prob.initialized_p ()
+ && prob.to_reg_br_prob_base () >= (int) (REG_BR_PROB_BASE * 3 / 8U)
+ && prob.to_reg_br_prob_base () <= (int) (REG_BR_PROB_BASE * 5 / 8U))
+ {
+ msw_taken_prob = prob.apply_scale (1, 2);
+ msw_skip_prob = rev_prob.apply_scale (REG_BR_PROB_BASE,
+ rev_prob.to_reg_br_prob_base ()
+ + REG_BR_PROB_BASE);
lsw_taken_prob = prob;
}
else
{
msw_taken_prob = prob;
- msw_skip_prob = REG_BR_PROB_BASE;
+ msw_skip_prob = profile_probability::guessed_always ();
/* ??? If we have a constant op2h, should we use that when
calculating lsw_taken_prob? */
lsw_taken_prob = prob;
diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md
index e19e977..733c777 100644
--- a/gcc/config/sh/sh.md
+++ b/gcc/config/sh/sh.md
@@ -1188,7 +1188,7 @@
(clobber (reg:SI T_REG))]
"can_create_pseudo_p ()"
{
- expand_cbranchsi4 (operands, LAST_AND_UNUSED_RTX_CODE, -1);
+ expand_cbranchsi4 (operands, LAST_AND_UNUSED_RTX_CODE);
DONE;
})