From: Torbjorn SVENSSON <torbjorn.svensson@foss.st.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>,
Alexandre Oliva <oliva@adacore.com>
Cc: Jonathan Wakely <jwakely@redhat.com>,
gcc-patches <gcc-patches@gcc.gnu.org>,
libstdc++ <libstdc++@gcc.gnu.org>,
Yvan Roux <yvan.roux@foss.st.com>
Subject: Re: [PATCH v2] libstdc++: optimize bit iterators assuming normalization [PR110807]
Date: Wed, 7 Feb 2024 17:25:46 +0100 [thread overview]
Message-ID: <275f454b-537a-44d2-8aae-85e4484d9c52@foss.st.com> (raw)
In-Reply-To: <CAH6eHdSknFCEqo+EtuLQFkw_CeO+dOd3GM=vKO4JgAN2ryKn7g@mail.gmail.com>
Hi,
Is it okay to backport e39b3e02c27bd771a07e385f9672ecf1a45ced77 to
releases/gcc-13?
Without this backport, I see this failure on arm-none-eabi:
FAIL: 23_containers/vector/bool/110807.cc (test for excess errors)
Kind regards,
Torbjörn
On 2023-11-09 02:22, Jonathan Wakely wrote:
>
>
> On Thu, 9 Nov 2023, 01:17 Alexandre Oliva, <oliva@adacore.com
> <mailto:oliva@adacore.com>> wrote:
>
> On Nov 8, 2023, Jonathan Wakely <jwakely@redhat.com
> <mailto:jwakely@redhat.com>> wrote:
>
> > A single underscore prefix on __GLIBCXX_BUILTIN_ASSUME and
> > __GLIBCXX_DISABLE_ASSUMPTIONS please.
>
> That's entirely gone now.
>
> >> + do \
> >> + if (std::is_constant_evaluated ()) \
> >> + static_assert(expr); \
>
> > This can never be valid.
>
> *nod*
>
> > This already works fine in constant evaluation anyway.
>
> Yeah, that's what I figured.
>
> > But what's the null dereference for?
>
> The idea was to clearly trigger undefined behavior. Maybe it wasn't
> needed, it didn't occur to me that __builtin_unreachable() would be
> enough. I realize I was really trying to emulate attribute assume, even
> without knowing it existed ;-)
>
> >> +#define __GLIBCXX_BUILTIN_ASSUME(expr) \
> >> + (void)(false && (expr))
>
> > What's the point of this, just to verify that (expr) is contextually
> > convertible to bool?
>
> I'd have phrased it as "avoid the case in which something compiles with
> -O0 but not with -O", but yeah ;-)
>
> > We don't use the _p suffix for predicates in the library.
> > Please use just _M_normalized or _M_is_normalized.
>
> ACK. It's also gone now.
>
> > But do we even need this function? It's not used anywhere else,
> can we
> > just inline the condition into _M_assume_normalized() ?
>
> I had other uses for it in earlier versions of the patch, but it makes
> no sense any more indeed.
>
> >> + _GLIBCXX20_CONSTEXPR
> >> + void
> >> + _M_assume_normalized() const
>
> > I think this should use _GLIBCXX_ALWAYS_INLINE
>
> *nod*, thanks
>
> >> + {
> >> + __GLIBCXX_BUILTIN_ASSUME (_M_normalized_p ());
>
> > Is there even any benefit to this macro?
>
> I just thought it could have other uses, without being aware that the
> entire concept was available as a statement attribute. Funny, I'd even
> searched for it among the existing attributes and builtins, but somehow
> I managed to miss it. Thanks for getting me back down that path.
>
> > __attribute__((__assume__(_M_offset <
> unsigned(_S_word_bit))));
>
> That unfortunately doesn't work, because the assume lowering doesn't go
> as far as dereferencing the implicit this and making an SSA_NAME out of
> the loaded _M_offset, which we'd need to be able to optimize based on
> it. But that only took me a while to figure out and massage into
> something that had the desired effect. Now, maybe the above *should*
> have that effect already, but unfortunately it doesn't.
>
> > Maybe even get rid of _M_assume_normalized() as a function and just
> > put that attribute everywhere you currently use _M_assume_normalized.
>
> Because of the slight kludge required to make the attribute have the
> desired effect (namely ensuring the _M_offset reference is evaluated),
> I've retained it as an inline function.
>
> Here's what I'm retesting now. WDYT?
>
>
> ofst needs to be __ofst but OK for trunk with that change.
>
> We probably want this on the gcc-13 branch too, but let's give it some
> time on trunk in case the assume attribute isn't quite ready for prime time.
next prev parent reply other threads:[~2024-02-07 16:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 16:10 [PATCH] " Alexandre Oliva
2023-11-08 19:32 ` Jonathan Wakely
2023-11-09 1:17 ` [PATCH v2] " Alexandre Oliva
2023-11-09 1:22 ` Jonathan Wakely
2023-11-09 3:36 ` [PATCH v3] " Alexandre Oliva
2023-11-09 5:57 ` François Dumont
2023-11-09 8:16 ` Jonathan Wakely
2023-11-09 19:49 ` [PATCH] libstdc++: bvector: undef always_inline macro Alexandre Oliva
2023-11-09 20:18 ` Jonathan Wakely
2023-11-15 2:20 ` Patrick Palka
2023-11-15 5:53 ` Alexandre Oliva
2023-11-15 2:44 ` Alexandre Oliva
2023-11-15 5:08 ` Alexandre Oliva
2023-11-15 8:22 ` Jonathan Wakely
2023-11-16 4:40 ` Alexandre Oliva
2024-02-07 16:25 ` Torbjorn SVENSSON [this message]
2024-02-07 16:36 ` [PATCH v2] libstdc++: optimize bit iterators assuming normalization [PR110807] Jonathan Wakely
2024-02-09 8:49 ` Torbjorn SVENSSON
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=275f454b-537a-44d2-8aae-85e4484d9c52@foss.st.com \
--to=torbjorn.svensson@foss.st.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely.gcc@gmail.com \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
--cc=oliva@adacore.com \
--cc=yvan.roux@foss.st.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).