public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/65893] New: ifcombine not done anymore on expansion of va_arg
Date: Sun, 26 Apr 2015 11:22:00 -0000	[thread overview]
Message-ID: <bug-65893-4@http.gcc.gnu.org/bugzilla/> (raw)

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

...


             reply	other threads:[~2015-04-26 11:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-26 11:22 vries at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65893-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).