diff options
Diffstat (limited to 'gcc/ipa-utils.c')
-rw-r--r-- | gcc/ipa-utils.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c index 73151248234..708710d6135 100644 --- a/gcc/ipa-utils.c +++ b/gcc/ipa-utils.c @@ -404,14 +404,17 @@ ipa_merge_profiles (struct cgraph_node *dst, /* FIXME when we merge in unknown profile, we ought to set counts as unsafe. */ - if (!dst->count.initialized_p ()) + if (!src->count.initialized_p ()) return; if (symtab->dump_file) { fprintf (symtab->dump_file, "Merging profiles of %s to %s\n", src->dump_name (), dst->dump_name ()); } - dst->count += src->count; + if (dst->count.initialized_p ()) + dst->count += src->count; + else + dst->count = src->count; /* This is ugly. We need to get both function bodies into memory. If declaration is merged, we need to duplicate it to be able @@ -521,12 +524,20 @@ ipa_merge_profiles (struct cgraph_node *dst, unsigned int i; dstbb = BASIC_BLOCK_FOR_FN (dstcfun, srcbb->index); - dstbb->count += srcbb->count; + if (dstbb->count.initialized_p ()) + dstbb->count += srcbb->count; + else + dstbb->count = srcbb->count; for (i = 0; i < EDGE_COUNT (srcbb->succs); i++) { edge srce = EDGE_SUCC (srcbb, i); edge dste = EDGE_SUCC (dstbb, i); - dste->count += srce->count; + if (dstbb->count.initialized_p ()) + dste->count += srce->count; + else + dste->count = srce->count; + if (dstbb->count > 0 && dste->count.initialized_p ()) + dste->probability = dste->count.probability_in (dstbb->count); } } push_cfun (dstcfun); @@ -598,7 +609,8 @@ ipa_merge_profiles (struct cgraph_node *dst, } } int prob = direct->count.probability_in (direct->count - + indirect->count); + + indirect->count). + to_reg_br_prob_base (); direct->frequency = RDIV (freq * prob, REG_BR_PROB_BASE); indirect->frequency = RDIV (freq * (REG_BR_PROB_BASE - prob), REG_BR_PROB_BASE); @@ -616,7 +628,8 @@ ipa_merge_profiles (struct cgraph_node *dst, e2->speculative_call_info (direct, indirect, ref); e->count = count; e->frequency = freq; - int prob = direct->count.probability_in (e->count); + int prob = direct->count.probability_in (e->count) + .to_reg_br_prob_base (); e->make_speculative (direct->callee, direct->count, RDIV (freq * prob, REG_BR_PROB_BASE)); } |