This is the mail archive of the gcc-patches@gcc.gnu.org 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: [PATCH, PR tree-optimization/65002] Disable SRA for functions wrongly marked as read-only


2015-02-13 11:54 GMT+03:00 Jakub Jelinek <jakub@redhat.com>:
> On Fri, Feb 13, 2015 at 09:47:56AM +0100, Richard Biener wrote:
>> > 2015-02-12  Ilya Enkovich  <ilya.enkovich@intel.com>
>> >
>> >         PR tree-optimization/65002
>> >         * tree-cfg.c (pass_data_fixup_cfg): Don't update
>> >         SSA on start.
>> >         * tree-sra.c (some_callers_have_no_vuse_p): New.
>> >         (ipa_early_sra): Reject functions whose callers
>> >         assume funciton is read only.
>
> Typo, function.
>
>> > +static bool
>> > +some_callers_have_no_vuse_p (struct cgraph_node *node,
>> > +                            void *data ATTRIBUTE_UNUSED)
>> > +{
>> > +  struct cgraph_edge *cs;
>> > +  for (cs = node->callers; cs; cs = cs->next_caller)
>> > +    if (!cs->call_stmt || !gimple_vuse (cs->call_stmt))
>> > +      return true;
>> > +
>> > +  return false;
>> > +}
>> > +
>> >  /* Convert all callers of NODE.  */
>> >
>> >  static bool
>> > @@ -5116,6 +5130,15 @@ ipa_early_sra (void)
>> >        goto simple_out;
>> >      }
>> >
>> > +  if (node->call_for_symbol_thunks_and_aliases
>> > +       (some_callers_have_no_vuse_p, NULL, true))
>> > +    {
>> > +      if (dump_file)
>> > +       fprintf (dump_file, "There are callers with no VUSE attached "
>> > +                "to a call stmt.\n");
>> > +      goto simple_out;
>> > +    }
>> > +
>
> I wonder if this won't pessimize const functions that just get called with
> aggregate arguments passed by value, do those count as memory read or
> just as parameters?

Tried it on a simple test.

struct S
{
  int a;
  int b;
};
int f1 (struct S s) __attribute__((const));
int f2 (struct S *ps)
{
  return f1 (*ps);
}

There is a memory use for a call:

  <bb 2>:
  # VUSE <.MEM_1(D)>
  _3 = f1 (*ps_2(D));


But if wrongly marked const function has all calls with vuses for some
reason then we just should be able to optimize it with a proper SSA
update.

Ilya

>
>         Jakub


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