From: Jonathan Wakely <jwakely@redhat.com>
To: Torbjorn SVENSSON <torbjorn.svensson@foss.st.com>
Cc: Jonathan Wakely <jwakely.gcc@gmail.com>,
Alexandre Oliva <oliva@adacore.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 16:36:43 +0000 [thread overview]
Message-ID: <CACb0b4=-Jik0fAOJonhdEoVRdenur6gwEYDvUpZrsvFCaWYdoA@mail.gmail.com> (raw)
In-Reply-To: <275f454b-537a-44d2-8aae-85e4484d9c52@foss.st.com>
[-- Attachment #1: Type: text/plain, Size: 4430 bytes --]
On Wed, 7 Feb 2024 at 16:25, Torbjorn SVENSSON <
torbjorn.svensson@foss.st.com> wrote:
> Hi,
>
> Is it okay to backport e39b3e02c27bd771a07e385f9672ecf1a45ced77 to
> releases/gcc-13?
>
It would also need 807f47497f17ed50be91f0f879308cb6fa063966
Please test with that as well, and OK for both if all goes well.
> 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:37 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 ` [PATCH v2] libstdc++: optimize bit iterators assuming normalization [PR110807] Torbjorn SVENSSON
2024-02-07 16:36 ` Jonathan Wakely [this message]
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='CACb0b4=-Jik0fAOJonhdEoVRdenur6gwEYDvUpZrsvFCaWYdoA@mail.gmail.com' \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely.gcc@gmail.com \
--cc=libstdc++@gcc.gnu.org \
--cc=oliva@adacore.com \
--cc=torbjorn.svensson@foss.st.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).