From: Richard Biener <richard.guenther@gmail.com>
To: Matthias Kretz <m.kretz@gsi.de>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Hongtao Liu <crazylht@gmail.com>
Subject: Re: [RFC] c-family: Add __builtin_noassoc
Date: Mon, 19 Jul 2021 09:16:19 +0200 [thread overview]
Message-ID: <CAFiYyc0HkCfU0JvCncMpZ9nP0pE_F142sHeqMjaReY4+DwkO_g@mail.gmail.com> (raw)
In-Reply-To: <1685995.5r07IH9sy9@excalibur>
On Fri, Jul 16, 2021 at 2:00 PM Matthias Kretz <m.kretz@gsi.de> wrote:
>
> On Friday, 16 July 2021 11:31:29 CEST Richard Biener wrote:
> > On Fri, Jul 16, 2021 at 10:57 AM Matthias Kretz <m.kretz@gsi.de> wrote:
> > > On Wednesday, 14 July 2021 10:14:55 CEST Richard Biener wrote:
> > > > I think implementing it similar to how we do __builtin_shufflevector
> > > > would
> > > > be easily possible. PAREN_EXPR is a tree code.
> > >
> > > Like this? If you like it, I'll write the missing documentation and do
> > > real
> > > regression testing.
> >
> > Yes, like this. Now, __builtin_noassoc (a + b + c) might suggest that
> > it prevents a + b + c from being re-associated - but it does not.
> > PAREN_EXPR is a barrier for association, so for 'a + b + c + PAREN_EXPR <d
> > + e + f>' the a+b+c and d+e+f chains will not mix but they individually can
> > be re-associated. That said __builtin_noassoc might be a bad name,
> > maybe __builtin_assoc_barrier is better?
>
> Yes, I agree with renaming it. And assoc_barrier sounds intuitive to me.
>
> > To fully prevent association of a a + b + d + e chain you need at least
> > two PAREN_EXPRs, for example (a+b) + (d+e) would do.
> >
> > One could of course provide __builtin_noassoc (a+b+c+d) with the
> > implied semantics and insert PAREN_EXPRs around all operands
> > when lowering it.
>
> I wouldn't want to go there. __builtin_noassoc(f(x, y, z))? We probably both
> agree that it would be a no-op, but it reads like f should be evaluated with -
> fno-associative-math.
Ah, true - yeah, let's not go down this rathole.
> > Not sure what's more useful in practice - directly exposing the middle-end
> > PAREN_EXPR or providing a way to mark a whole expression as to be
> > not re-associated? Maybe both?
>
> I think this is a tool for specialists. Give them the low-level tool and
> they'll build whatever higher level abstractions they need on top of it. Like
OK, fine.
> float sum_noassoc(RangeOfFloats auto x) {
> float sum = 0;
> for (float v : x)
> sum = __builtin_assoc_barrier(v + x);
> return sum;
> }
>
> --
> ──────────────────────────────────────────────────────────────────────────
> Dr. Matthias Kretz https://mattkretz.github.io
> GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
> std::experimental::simd https://github.com/VcDevel/std-simd
> ──────────────────────────────────────────────────────────────────────────
prev parent reply other threads:[~2021-07-19 7:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 5:15 [Questions] Is there any bit in gimple/rtl to indicate this IR support fast-math or not? Hongtao Liu
2021-07-14 5:18 ` Hongtao Liu
2021-07-14 6:39 ` Matthias Kretz
2021-07-14 7:04 ` Hongtao Liu
2021-07-14 7:39 ` Richard Biener
2021-07-14 16:45 ` Segher Boessenkool
[not found] ` <47833128.jc7mZyZMxp@excalibur>
[not found] ` <CAFiYyc2t690=B77Mwb9=-T_TzQvZUj7RnFVDmuaWDJBN81DtHw@mail.gmail.com>
2021-07-16 8:57 ` [RFC] c-family: Add __builtin_noassoc Matthias Kretz
2021-07-16 9:31 ` Richard Biener
2021-07-16 12:00 ` Matthias Kretz
2021-07-19 7:16 ` Richard Biener [this message]
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=CAFiYyc0HkCfU0JvCncMpZ9nP0pE_F142sHeqMjaReY4+DwkO_g@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=crazylht@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=m.kretz@gsi.de \
/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).