This patch prevents integer-underflow of badness computation in ipa-inline.
Bootstrapped and passed regression tests. OK for trunk? Thanks, Dehao gcc/ChangeLog: 2013-06-21 Dehao Chen <de...@google.com> * ipa-inline.c (edge_badness): Fix integer underflow. Index: gcc/ipa-inline.c =================================================================== --- gcc/ipa-inline.c (revision 200326) +++ gcc/ipa-inline.c (working copy) @@ -888,11 +888,9 @@ edge_badness (struct cgraph_edge *edge, bool dump) else if (max_count) { int relbenefit = relative_time_benefit (callee_info, edge, edge_time); - badness = - ((int) - ((double) edge->count * INT_MIN / 2 / max_count / RELATIVE_TIME_BENEFIT_RANGE) * - relbenefit) / growth; - + badness = ((int)((double) edge->count / max_count + * relbenefit / RELATIVE_TIME_BENEFIT_RANGE * INT_MIN / 2)) / growth; + /* Be sure that insanity of the profile won't lead to increasing counts in the scalling and thus to overflow in the computation above. */ gcc_assert (max_count >= edge->count);