* [PATCH, PR 49786] Avoid overflow when updating counts in IPA-CP
@ 2011-07-26 13:04 Martin Jambor
2011-07-26 13:17 ` Jan Hubicka
0 siblings, 1 reply; 2+ messages in thread
From: Martin Jambor @ 2011-07-26 13:04 UTC (permalink / raw)
To: GCC Patches; +Cc: Jan Hubicka
Hi,
the issue in PR 49786 has been well summarized in comment #12.
Basically, the multiplication we do when updating counts of edges
overflows. I looked at how this was handled previously in IPA-CP and
the following should be an equivalent solution.
This patch fixes the LTO profiled bootstrap and I have tested it by
doing a usual non-LTO and non-profiled bootstrap and testsuite
(without any issues) run as well as running the testsuite on the
compiler produced by the LTO profiled bootstrap. I compared the
second set of testsuite results with both the results obtained from a
revision before the IPA-CP submission and the current normal bootstrap
ones and it seemed fine (although there were a few dump scan
failures). (All of the above was done on x86_64-linux.)
So, OK for trunk?
Thanks,
Martin
2011-07-25 Martin Jambor <mjambor@suse.cz>
PR bootstrap/49786
* ipa-cp.c (update_profiling_info): Avoid overflow when updating
counts.
(update_specialized_profile): Likewise.
Index: src/gcc/ipa-cp.c
===================================================================
--- src.orig/gcc/ipa-cp.c
+++ src/gcc/ipa-cp.c
@@ -1877,7 +1877,6 @@ dump_profile_updates (struct cgraph_node
cgraph_node_name (cs->callee), (HOST_WIDE_INT) cs->count);
}
-
/* After a specialized NEW_NODE version of ORIG_NODE has been created, update
their profile information to reflect this. */
@@ -1923,12 +1922,14 @@ update_profiling_info (struct cgraph_nod
for (cs = new_node->callees; cs ; cs = cs->next_callee)
if (cs->frequency)
- cs->count = cs->count * new_sum / orig_node_count;
+ cs->count = cs->count * (new_sum * REG_BR_PROB_BASE
+ / orig_node_count) / REG_BR_PROB_BASE;
else
cs->count = 0;
for (cs = orig_node->callees; cs ; cs = cs->next_callee)
- cs->count = cs->count * remainder / orig_node_count;
+ cs->count = cs->count * (remainder * REG_BR_PROB_BASE
+ / orig_node_count) / REG_BR_PROB_BASE;
if (dump_file)
dump_profile_updates (orig_node, new_node);
@@ -1966,7 +1967,8 @@ update_specialized_profile (struct cgrap
for (cs = orig_node->callees; cs ; cs = cs->next_callee)
{
- gcov_type dec = cs->count * redirected_sum / orig_node_count;
+ gcov_type dec = cs->count * (redirected_sum * REG_BR_PROB_BASE
+ / orig_node_count) / REG_BR_PROB_BASE;
if (dec < cs->count)
cs->count -= dec;
else
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, PR 49786] Avoid overflow when updating counts in IPA-CP
2011-07-26 13:04 [PATCH, PR 49786] Avoid overflow when updating counts in IPA-CP Martin Jambor
@ 2011-07-26 13:17 ` Jan Hubicka
0 siblings, 0 replies; 2+ messages in thread
From: Jan Hubicka @ 2011-07-26 13:17 UTC (permalink / raw)
To: GCC Patches, Jan Hubicka
> Hi,
>
> the issue in PR 49786 has been well summarized in comment #12.
> Basically, the multiplication we do when updating counts of edges
> overflows. I looked at how this was handled previously in IPA-CP and
> the following should be an equivalent solution.
>
> This patch fixes the LTO profiled bootstrap and I have tested it by
> doing a usual non-LTO and non-profiled bootstrap and testsuite
> (without any issues) run as well as running the testsuite on the
> compiler produced by the LTO profiled bootstrap. I compared the
> second set of testsuite results with both the results obtained from a
> revision before the IPA-CP submission and the current normal bootstrap
> ones and it seemed fine (although there were a few dump scan
> failures). (All of the above was done on x86_64-linux.)
>
> So, OK for trunk?
Ok, thanks
as a general rule we can't do second power of count in 64bit value, so my referred
solution is this REG_BR_PROB_BASE fixed point math.
Honza
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-26 11:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26 13:04 [PATCH, PR 49786] Avoid overflow when updating counts in IPA-CP Martin Jambor
2011-07-26 13:17 ` Jan Hubicka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).