public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/95383] Poor codegen when constructing a trivial Optional
Date: Fri, 29 May 2020 06:21:01 +0000	[thread overview]
Message-ID: <bug-95383-4-XcIU5NuTIx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95383-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2020-05-29
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I see the cited -O3 code-gen with -O2 on trunk.  We expand from

foo (bool b)
{
  struct Optional D.2251;
  unsigned char _7;

  <bb 2> [local count: 1073741824]:
  if (b_2(D) != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870913]:
  D.2251.D.2152.value = 42;

  <bb 4> [local count: 1073741824]:
  # _7 = PHI <1(3), 0(2)>
  MEM <unsigned char> [(struct Optional *)&D.2251 + 4B] = _7;
  return D.2251;

where the main issue is likely we fail to elide D.2251 because of the
aggregate return (and us not exposing the ABI, etc.).

Note above D.2251 is partly initialized which makes it a bit more difficult
to optimize.  SRA might try to handle these cases by rematerializing the
aggregate just before the return.  We can then hope for RTL expansion
to do "magic".

  reply	other threads:[~2020-05-29  6:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 13:56 [Bug c++/95383] New: " barry.revzin at gmail dot com
2020-05-29  6:21 ` rguenth at gcc dot gnu.org [this message]
2021-12-17  5:33 ` [Bug middle-end/95383] " pinskia at gcc dot gnu.org
2023-07-12 21:35 ` pinskia 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-95383-4-XcIU5NuTIx@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).