public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/102452] Structs with flexible array members are not optimized on stack
Date: Thu, 23 Sep 2021 06:57:23 +0000	[thread overview]
Message-ID: <bug-102452-4-ES2dQ0SfFP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102452-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
get_three after einline w/o USE_FLEX_ARR defined (this is changing the type to
int):

  <bb 2> :
  _5 = test_2(D)->is_a;
  if (_5 != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> :
  D.3292 = *test_2(D);
  goto <bb 5>; [100.00%]

  <bb 4> :
  _6 = test_2(D)->as.b.one;
  _7 = (long int) _6;
  _8 = test_2(D)->as.b.two;
  _9 = (long int) _8;
  _10 = test_2(D)->as.b.three;
  _11 = (long int) _10;
  D.3292.as.a.one = _7;
  D.3292.as.a.two = _9;
  D.3292.as.a.three = _11;

  <bb 5> :
  _4 = D.3292.as.a.three;
  return _4;

With USE_FLEX_ARR defined to 1:
  <bb 2> :
  _5 = test_2(D)->is_a;
  if (_5 != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> :
  D.3293 = *test_2(D);
  goto <bb 5>; [100.00%]

  <bb 4> :
  _6 = test_2(D)->as.b.one;
  _7 = (long int) _6;
  ret.as.a.one = _7;
  _8 = test_2(D)->as.b.two;
  _9 = (long int) _8;
  ret.as.a.two = _9;
  _10 = test_2(D)->as.b.three;
  _11 = (long int) _10;
  ret.as.a.three = _11;
  D.3293 = ret;
  ret ={v} {CLOBBER};

  <bb 5> :
  _4 = D.3293.as.a.three;
  return _4;


as far as I can tell the IR is the same before that,
even RSO:
  D.3293 = make_test_a (test_2(D)); [return slot optimization]


But it looks in the case of the flex array case, RSO does not actually happen.

  parent reply	other threads:[~2021-09-23  6:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 13:22 [Bug c/102452] New: " peter at peterzhu dot ca
2021-09-22 17:49 ` [Bug ipa/102452] " pinskia at gcc dot gnu.org
2021-09-23  6:42 ` rguenth at gcc dot gnu.org
2021-09-23  6:57 ` pinskia at gcc dot gnu.org [this message]
2021-09-23  7:05 ` [Bug tree-optimization/102452] " pinskia at gcc dot gnu.org
2021-09-23  7:16 ` rguenther at suse dot de
2021-09-23  7:21 ` rguenther at suse dot de

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-102452-4-ES2dQ0SfFP@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).