This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Massive performance regression from switching to gcc 4.5

On Thu, Jun 24, 2010 at 10:24 PM, Eric Botcazou <> wrote:
>> In addition, it appears at first glance that GCC is either no longer
>> inlining at -Os, even when it would be a size advantage to do so, or is
>> making some very poor inlining choices.
>> e.g. +72 ? ? ?nsTArray<ObserverRef>::nsTArray(nsTArray<ObserverRef> const&)
>> We can turn some of these observations into bug reports if that would be
>> helpful, but if it would make more sense we could perhaps just tune the
>> inlining parameters directly to get the "real -Os" that we usually want.
> We ran into similar inlining regressions in Ada, the heuristics have indeed
> changed significantly. ?The attached patchlet alone saves 3% in code size
> at -Os on a 50 MB executable and yields a 5% speedup at -O2 on another code.
> ? ? ? ?* ipa-inline.c (likely_eliminated_by_inlining_p): Really consider that
> ? ? ? ?loads from parameters passed by reference are free after inlining.

I don't understand this change.  Minus whitespace changes it seems to be

!           if (lhs_free && (is_gimple_reg (rhs) ||
is_gimple_min_invariant (rhs)))
              rhs_free = true;


!           if (lhs_free
!               && (is_gimple_reg (rhs)
!                   || !is_gimple_reg_type (TREE_TYPE (rhs))
!                   || is_gimple_min_invariant (rhs)))
              rhs_free = true;

so the stmt is likely being eliminated if either the LHS or the RHS is based
on a parameter and the other side is a register or an invariant.  You change
that to also discount aggregate stores/loads to/from parameters to be

Which you could have simplified to just say

  if (lhs_free || rhs_free)
    return true;

and drop the code you are changing.

I never considered the heuristic making loads/stores from parameters
free a very good one.  It makes *p free but not *(p+1) for example.
I would rather have seen the call stmts actual argument list to
be considered.

There are btw. some bugs wrt accounting of functions called once
being inlined in 4.5 which were fixed on trunk which allow extra
inlining.  See

2010-04-13  Jan Hubicka  <>

        * ipa-inline.c (cgraph_mark_inline_edge): Avoid double accounting
        of optimized out static functions.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]