Hi,
the attached patches avoids use of REG_BR_PROB_BASE based fixpoint artihmetics
where
it is easy to do.
Bootstrapped/regtested x86_64-linux, comitted.
Honza
* asan.c (create_cond_insert_point): Avoid use of REG_BR_PROB_BASE
fixpoint arithmetics.
Index: asan.c
===================================================================
--- asan.c (revision 250239)
+++ asan.c (working copy)
@@ -1798,12 +1798,11 @@ create_cond_insert_point (gimple_stmt_it
/* Set up the newly created 'then block'. */
e = make_edge (cond_bb, then_bb, EDGE_TRUE_VALUE);
- int fallthrough_probability
+ profile_probability fallthrough_probability
= then_more_likely_p
- ? PROB_VERY_UNLIKELY
- : PROB_ALWAYS - PROB_VERY_UNLIKELY;
- e->probability = profile_probability::from_reg_br_prob_base
- (PROB_ALWAYS - fallthrough_probability);
+ ? profile_probability::very_unlikely ()
+ : profile_probability::very_likely ();
+ e->probability = fallthrough_probability.invert ();
if (create_then_fallthru_edge)
make_single_succ_edge (then_bb, fallthru_bb, EDGE_FALLTHRU);
@@ -1811,8 +1810,7 @@ create_cond_insert_point (gimple_stmt_it
e = find_edge (cond_bb, fallthru_bb);
e->flags = EDGE_FALSE_VALUE;
e->count = cond_bb->count;
- e->probability
- = profile_probability::from_reg_br_prob_base (fallthrough_probability);
+ e->probability = fallthrough_probability;
/* Update dominance info for the newly created then_bb; note that
fallthru_bb's dominance info has already been updated by
2017-07-16 Jan Hubicka <[email protected]>
* tree-ssa-loop-unswitch.c (hoist_guard): Avoid use of REG_BR_PROB_BASE
fixpoint arithmetics.
Index: tree-ssa-loop-unswitch.c
===================================================================
--- tree-ssa-loop-unswitch.c (revision 250239)
+++ tree-ssa-loop-unswitch.c (working copy)
@@ -897,9 +897,7 @@ hoist_guard (struct loop *loop, edge gua
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " %i", bb->index);
if (e->probability.initialized_p ())
- scale_bbs_frequencies_int (&bb, 1,
- e->probability.to_reg_br_prob_base (),
- REG_BR_PROB_BASE);
+ scale_bbs_frequencies (&bb, 1, e->probability);
}
}
* cfgloopmanip.c (scale_loop_profile): Avoid use of REG_BR_PROB_BASE
fixpoint arithmetics.
Index: cfgloopmanip.c
===================================================================
--- cfgloopmanip.c (revision 250241)
+++ cfgloopmanip.c (working copy)
@@ -546,8 +546,8 @@ scale_loop_profile (struct loop *loop, p
/* Probability of exit must be 1/iterations. */
freq_delta = EDGE_FREQUENCY (e);
- e->probability = profile_probability::from_reg_br_prob_base
- (REG_BR_PROB_BASE / iteration_bound);
+ e->probability = profile_probability::always ()
+ .apply_scale (1, iteration_bound);
other_e->probability = e->probability.invert ();
freq_delta -= EDGE_FREQUENCY (e);
* cgraph.c (cgraph_edge::redirect_call_stmt_to_caller): Cleanup.
Index: cgraph.c
===================================================================
--- cgraph.c (revision 250241)
+++ cgraph.c (working copy)
@@ -1315,19 +1315,19 @@ cgraph_edge::redirect_call_stmt_to_calle
}
gcc_assert (e2->speculative);
push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl));
+
+ profile_probability prob = e->count.probability_in (e->count
+ + e2->count);
+ if (prob.initialized_p ())
+ ;
+ else if (e->frequency || e2->frequency)
+ prob = profile_probability::probability_in_gcov_type
+ (e->frequency, e->frequency + e2->frequency).guessed ();
+ else
+ prob = profile_probability::even ();
new_stmt = gimple_ic (e->call_stmt,
dyn_cast<cgraph_node *> (ref->referred),
- /* FIXME: cleanup. */
- profile_probability::from_reg_br_prob_base (
- e->count > profile_count::zero ()
- || e2->count > profile_count::zero ()
- ? e->count.probability_in
- (e->count + e2->count).to_reg_br_prob_base ()
- : e->frequency || e2->frequency
- ? RDIV (e->frequency * REG_BR_PROB_BASE,
- e->frequency + e2->frequency)
- : REG_BR_PROB_BASE / 2),
- e->count, e->count + e2->count);
+ prob, e->count, e->count + e2->count);
e->speculative = false;
e->caller->set_call_stmt_including_clones (e->call_stmt, new_stmt,
false);