From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "☂Josh Chia (謝任中)" <joshchia@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Generated assembly code for returning std::optional<uint32_t>
Date: Thu, 28 Oct 2021 10:55:11 +0100 [thread overview]
Message-ID: <CAH6eHdS-wQsKUC+fZ7Mh4tNzySWR3uqgKWKBGQaOmxU6HDhk-A@mail.gmail.com> (raw)
In-Reply-To: <CALxtSbTM7OT1K-_Z5h36q0Co=LAm-FZpezmZH=DB1hnmb+DT+g@mail.gmail.com>
On Thu, 28 Oct 2021 at 08:11, ☂Josh Chia (謝任中) via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> Under -O3 -std=c++17, the assembly code generated by gcc 11.2 for some
> std::optional C++ code seems less optimal than I expect; it is writing the
> content of optional<uint64_t> return values to both the stack and to the
> RAX register. What am I missing? I was under the impression that return
> values are put in RAX if they can fit. Why does gcc have to write the
> return value to both the stack and RAX instead of just one of them? Can the
> writing to the stack be avoided?
Is this https://gcc.gnu.org/PR101326 ?
next prev parent reply other threads:[~2021-10-28 9:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 7:10 ☂Josh Chia (謝任中)
2021-10-28 9:55 ` Jonathan Wakely [this message]
2021-10-28 10:54 ` ☂Josh Chia (謝任中)
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=CAH6eHdS-wQsKUC+fZ7Mh4tNzySWR3uqgKWKBGQaOmxU6HDhk-A@mail.gmail.com \
--to=jwakely.gcc@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=joshchia@gmail.com \
/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).