+2017-11-06 Jan Hubicka <hubicka@ucw.cz>
+
+ PR bootstrap/82832
+ * ipa-inline-transform.c (update_noncloned_frequencies): Always
+ scale.
+ (inline_transform): Likewise.
+ * predict.c (counts_to_freqs): Remove useless conditional.
+ * profile-count.h (profile_count::apply_scale): Move sanity check.
+ * tree-inline.c (copy_bb): Always scale.
+ (copy_cfg_body): Likewise.
+
2017-11-06 Christophe Lyon <christophe.lyon@linaro.org>
PR target/67591
profile_count den)
{
struct cgraph_edge *e;
- bool scale = (num == profile_count::zero () || den > 0);
+
+ /* We always must scale to be sure counters end up compatible.
+ If den is zero, just force it nonzero and hope for reasonable
+ approximation.
+ When num is forced nonzero, also update den, so we do not scale profile
+ to 0. */
+ if (!(num == den)
+ && !(den.force_nonzero () == den))
+ {
+ den = den.force_nonzero ();
+ num = num.force_nonzero ();
+ }
/* We do not want to ignore high loop nest after freq drops to 0. */
if (!freq_scale)
e->frequency = CGRAPH_FREQ_MAX;
if (!e->inline_failed)
update_noncloned_frequencies (e->callee, freq_scale, num, den);
- if (scale)
- e->count = e->count.apply_scale (num, den);
+ e->count = e->count.apply_scale (num, den);
}
for (e = node->indirect_calls; e; e = e->next_callee)
{
e->frequency = e->frequency * (gcov_type) freq_scale / CGRAPH_FREQ_BASE;
if (e->frequency > CGRAPH_FREQ_MAX)
e->frequency = CGRAPH_FREQ_MAX;
- if (scale)
- e->count = e->count.apply_scale (num, den);
+ e->count = e->count.apply_scale (num, den);
}
- if (scale)
- node->count = node->count.apply_scale (num, den);
+ node->count = node->count.apply_scale (num, den);
}
/* We removed or are going to remove the last call to NODE.
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
- bb->count = bb->count.apply_scale (num, den);
+ if (num == profile_count::zero ())
+ bb->count = bb->count.global0 ();
+ else
+ bb->count = bb->count.apply_scale (num, den);
ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
}
todo = optimize_inline_calls (current_function_decl);
basic_block bb;
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb)
- if (!(bb->count < true_count_max))
- true_count_max = true_count_max.max (bb->count);
+ true_count_max = true_count_max.max (bb->count);
cfun->cfg->count_max = true_count_max;
return num;
if (!initialized_p () || !num.initialized_p () || !den.initialized_p ())
return profile_count::uninitialized ();
- gcc_checking_assert (den.m_val);
if (num == den)
return *this;
+ gcc_checking_assert (den.m_val);
profile_count ret;
uint64_t val;
basic_block copy_basic_block;
tree decl;
basic_block prev;
- bool scale = !num.initialized_p ()
- || (den.nonzero_p () || num == profile_count::zero ());
+
+ /* We always must scale to be sure counters end up compatible.
+ If den is zero, just force it nonzero and hope for reasonable
+ approximation.
+ When num is forced nonzero, also update den, so we do not scale profile
+ to 0. */
+ if (!(num == den)
+ && !(den.force_nonzero () == den))
+ {
+ den = den.force_nonzero ();
+ num = num.force_nonzero ();
+ }
/* Search for previous copied basic block. */
prev = bb->prev_bb;
/* create_basic_block() will append every new block to
basic_block_info automatically. */
copy_basic_block = create_basic_block (NULL, (basic_block) prev->aux);
- if (scale)
- copy_basic_block->count = bb->count.apply_scale (num, den);
- else if (num.initialized_p ())
- copy_basic_block->count = bb->count;
+ copy_basic_block->count = bb->count.apply_scale (num, den);
copy_gsi = gsi_start_bb (copy_basic_block);
profile_count den = ENTRY_BLOCK_PTR_FOR_FN (src_cfun)->count;
profile_count num = entry_block_map->count;
+ /* We always must scale to be sure counters end up compatible.
+ If den is zero, just force it nonzero and hope for reasonable
+ approximation.
+ When num is forced nonzero, also update den, so we do not scale profile
+ to 0. */
+ if (!(num == den)
+ && !(den.force_nonzero () == den))
+ {
+ den = den.force_nonzero ();
+ num = num.force_nonzero ();
+ }
+
cfun_to_copy = id->src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl);
/* Register specific tree functions. */