public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/65893] New: ifcombine not done anymore on expansion of va_arg
@ 2015-04-26 11:22 vries at gcc dot gnu.org
  2015-04-27  5:54 ` [Bug tree-optimization/65893] " vries at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2015-04-26 11:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65893
           Summary: ifcombine not done anymore on expansion of va_arg
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I observed the following when investigating the effect of the introduction of
ifn_va_arg for aarch64 on stdarg-1.c.

At optimized dump, before introduction of ifn_va_arg we have a single
comparison (_4 >= -7):
...
foo (int v, struct va_list ap)
{
  int * iftmp.0_1;
  int _4;
  void * _5;
  void * _7;
  sizetype _8;
  int * iftmp.1_9;
  int foo_arg.2_10;

  <bb 2>:
  switch (v_2(D)) <default: <L7>, case 5: <L0>>

<L0>:
  _4 = ap.__gr_offs;
  _5 = ap.__stack;
  if (_4 >= -7)
    goto <bb 5>;
  else
    goto <bb 4>;

  <bb 4>:
  _7 = ap.__gr_top;
  _8 = (sizetype) _4;
  iftmp.1_9 = _7 + _8;

  <bb 5>:
  # iftmp.0_1 = PHI <_5(3), iftmp.1_9(4)>
  foo_arg.2_10 = *iftmp.0_1;
  foo_arg = foo_arg.2_10;
  return;

<L7>:
  abort ();
}
...

After introduction of ifn_va_arg, we have two comparisons (ap$__gr_offs_20 >=
0, ap$__gr_offs_20 >= -7):
...
foo (int v, struct va_list ap)
{
  int ap$__gr_offs;
  void * ap$__stack;
  int * iftmp.28;
  int * iftmp.29;
  void * D.2827;
  sizetype D.2828;
  int foo_arg.0_4;

  <bb 2>:
  switch (v_1(D)) <default: <L1>, case 5: <L9>>

<L9>:
  ap$__stack_26 = MEM[(struct  *)&ap];
  ap$__gr_offs_20 = MEM[(struct  *)&ap + 24B];
  if (ap$__gr_offs_20 >= 0)
    goto <bb 7>;
  else
    goto <bb 4>;

  <bb 4>:
  if (ap$__gr_offs_20 >= -7)
    goto <bb 6>;
  else
    goto <bb 5>;

  <bb 5>:
  _28 = ap.__gr_top;
  _29 = (sizetype) ap$__gr_offs_20;
  iftmp.29_30 = _28 + _29;

  <bb 6>:
  # iftmp.29_10 = PHI <ap$__stack_26(4), iftmp.29_30(5)>

  <bb 7>:
  # iftmp.28_9 = PHI <ap$__stack_26(3), iftmp.29_10(6)>
  foo_arg.0_4 = *iftmp.28_9;
  foo_arg = foo_arg.0_4;
  return;

<L1>:
  abort ();
}
...

The tree optimization ifcombine can combine the two comparisons, so:

1. Before the introduction of ifn_va_arg, the va_arg is expanded at
gimplification, and ifcombine manages to combine the two comparisons.

2. After the introduction of ifn_va_arg, the va_arg is expanded at pass_starg,
a few steps after the ifcombine pass, and the optimization does not happen:
...
      NEXT_PASS (pass_tree_ifcombine);
      NEXT_PASS (pass_phiopt);
      NEXT_PASS (pass_tail_recursion);
      NEXT_PASS (pass_ch);
      NEXT_PASS (pass_stdarg);

...


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-29  9:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-26 11:22 [Bug tree-optimization/65893] New: ifcombine not done anymore on expansion of va_arg vries at gcc dot gnu.org
2015-04-27  5:54 ` [Bug tree-optimization/65893] " vries at gcc dot gnu.org
2015-04-27  9:24 ` rguenth at gcc dot gnu.org
2015-04-29  8:55 ` vries at gcc dot gnu.org
2015-04-29  9:14 ` vries at gcc dot gnu.org
2015-04-29  9:15 ` vries at gcc dot gnu.org

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).