* ipa-cp.c (ipcp_compute_node_scale): Work around completely
wrong profile updates.
* predict.c (counts_to_freqs): Be expected for ENTRY/EXIT block
having largest frequency.
* ira-live.c (ira_implicitly_set_insn_hard_regs): Silecne
used uninitalized warning.
* tree-optimize.c (execute_fixup_cfg): Rescale entry and exit block
frequencies.
From-SVN: r154462
+2009-11-23 Jan Hubicka <jh@suse.cz>
+
+ * ipa-cp.c (ipcp_compute_node_scale): Work around completely
+ wrong profile updates.
+ * predict.c (counts_to_freqs): Be expected for ENTRY/EXIT block
+ having largest frequency.
+ * ira-live.c (ira_implicitly_set_insn_hard_regs): Silecne
+ used uninitalized warning.
+ * tree-optimize.c (execute_fixup_cfg): Rescale entry and exit block
+ frequencies.
+
2009-11-23 Uros Bizjak <ubizjak@gmail.com>
* config/alpha/alpha.md (*cmp_sadd_sidi): Use gen_lowpart instead
2009-11-23 Uros Bizjak <ubizjak@gmail.com>
* config/alpha/alpha.md (*cmp_sadd_sidi): Use gen_lowpart instead
/* Compute the proper scale for NODE. It is the ratio between the number of
direct calls (represented on the incoming cgraph_edges) and sum of all
/* Compute the proper scale for NODE. It is the ratio between the number of
direct calls (represented on the incoming cgraph_edges) and sum of all
- invocations of NODE (represented as count in cgraph_node). */
+ invocations of NODE (represented as count in cgraph_node).
+
+ FIXME: This code is wrong. Since the callers can be also clones and
+ the clones are not scaled yet, the sums gets unrealistically high.
+ To properly compute the counts, we would need to do propagation across
+ callgraph (as external call to A might imply call to non-clonned B
+ if A's clone calls clonned B). */
static void
ipcp_compute_node_scale (struct cgraph_node *node)
{
static void
ipcp_compute_node_scale (struct cgraph_node *node)
{
/* Compute sum of all counts of callers. */
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
sum += cs->count;
/* Compute sum of all counts of callers. */
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
sum += cs->count;
+ /* Work around the unrealistically high sum problem. We just don't want
+ the non-cloned body to have negative or very low frequency. Since
+ majority of execution time will be spent in clones anyway, this should
+ give good enough profile. */
+ if (sum > node->count * 9 / 10)
+ sum = node->count * 9 / 10;
if (node->count == 0)
ipcp_set_node_scale (node, 0);
else
if (node->count == 0)
ipcp_set_node_scale (node, 0);
else
void
ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set)
{
void
ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set)
{
bool ignore_p;
enum reg_class cl;
rtx op;
bool ignore_p;
enum reg_class cl;
rtx op;
gcov_type count_max, true_count_max = 0;
basic_block bb;
gcov_type count_max, true_count_max = 0;
basic_block bb;
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
true_count_max = MAX (bb->count, true_count_max);
count_max = MAX (true_count_max, 1);
true_count_max = MAX (bb->count, true_count_max);
count_max = MAX (true_count_max, 1);
else
count_scale = REG_BR_PROB_BASE;
else
count_scale = REG_BR_PROB_BASE;
+ ENTRY_BLOCK_PTR->count = cgraph_node (current_function_decl)->count;
+ EXIT_BLOCK_PTR->count = (EXIT_BLOCK_PTR->count * count_scale
+ + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+
FOR_EACH_BB (bb)
{
bb->count = (bb->count * count_scale
FOR_EACH_BB (bb)
{
bb->count = (bb->count * count_scale