https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30908

Senthil Kumar Selvaraj <saaadhu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #22 from Senthil Kumar Selvaraj <saaadhu at gcc dot gnu.org> ---
This basically boils down to inconsistent estimated size cost to actual code
size ratio.
Without a -mmcu, the arch defaults to avr2, which supports only rcall. The
(hard coded) call cost size is 2, and rcall is 2 bytes long - the ratio of
estimated size cost to actual size is 1.

The (const propagated) wait function's size cost estimate is 6 (3 if inlined),
whereas the actual code code size is 12. The ratio is totally off now i.e. 2
instead of the 1 calculated for the call cost.

The wild variation in ratio makes ipa-inline is the root cause for the
inlining. For the first inline call, removing the call reduces cost by 2, and
plugging in the inline code increases it by 3, for an effective size cost
increase of 1. 

With the second inline call though, the callee can be eliminated, and the
calculated size cost is + 1 - 6 = -5. The total estimated size cost -5 + 1 = -4
i.e. smaller than the non-inlined case, and so ipa-inline decides to inline the
two calls.

Reply via email to