From: Richard Biener <richard.guenther@gmail.com>
To: Alexandre Oliva <oliva@adacore.com>
Cc: Jan Hubicka <hubicka@ucw.cz>,
GCC Patches <gcc-patches@gcc.gnu.org>, Zdenek Dvorak <ook@ucw.cz>
Subject: Re: [RFC] test builtin ratio for loop distribution
Date: Fri, 5 Feb 2021 09:02:41 +0100 [thread overview]
Message-ID: <CAFiYyc1sx3XiFWGowvjJiT7RU_6aX0eVQHnJwT9crskEyDAQSA@mail.gmail.com> (raw)
In-Reply-To: <oreehvtr3i.fsf@lxoliva.fsfla.org>
On Thu, Feb 4, 2021 at 11:18 PM Alexandre Oliva <oliva@adacore.com> wrote:
>
> On Feb 4, 2021, Richard Biener <richard.guenther@gmail.com> wrote:
>
> >> > b) if expansion would use BY_PIECES then expand to an unrolled loop
> >>
> >> Why would that be better than keeping the constant-length memset call,
> >> that would be turned into an unrolled loop during expand?
>
> > Well, because of the possibly lost ctz and alignment info.
>
> Funny you should mention that. I got started with the expand-time
> expansion yesterday, and found out that we're not using the alignment
> information that is available. Though the pointer is known to point to
> an aligned object, we are going for 8-bit alignment for some reason.
>
> The strategy I used there was to first check whether by_pieces would
> expand inline a constant length near the max known length, then loop
> over the bits in the variable length, expand in each iteration a
> constant-length store-by-pieces for the fixed length corresponding to
> that bit, and a test comparing the variable length with the fixed length
> guarding the expansion of the store-by-pieces. We may get larger code
> this way (no loops), but only O(log(len)) compares.
>
> I've also fixed some bugs in the ldist expander, so now it bootstraps,
> but with a few regressions in the testsuite, that I'm yet to look into.
>
> >> Uhh, thanks, but... you realize nearly all of the gimple-building code
> >> is one and the same for the loop and for trailing count misalignment?
>
> > Sorry, the code lacked comments and so I didn't actually try decipering
> > the code you generate ;)
>
> Oh, come on, it was planly obscure ;-D
>
> Sorry for posting an early-draft before polishing it up.
>
> > The original motivation was really that esp. for small trip count loops
> > the target knows best how to implement them. Now, that completely
> > fails of course in case the target doesn't implement any of this or
> > the generic code fails because we lost ctz and alignment info.
>
> In our case, generic code fails because it won't handle variable-sized
> clear-by-pieces. But then, I found out, when it's fixed-size, it also
> makes the code worse, because it seems to expand to byte stores even
> when the store-to object is known to have wider alignment:
>
> union u {
> long long i;
> char c[8];
> } x[8];
> int s(union u *p, int k) {
> for (int i = k ? 0 : 3; i < 8; i++) {
> for (int j = 0; j < 8; j++) {
> p[i].c[j] = 0;
> } // becomes a memset to an 8-byte-aligned 8-byte object, then 8 byte stores
> }
> }
On x86_64 I see two DImode stores generated, but that appears to be
done via setmem.
> >> > I think the builtins with alignment and calloc-style element count
> >> > will be useful on its own.
> >>
> >> Oh, I see, you're suggesting actual separate builtin functions. Uhh...
> >> I'm not sure I want to go there. I'd much rather recover the ctz of the
> >> length, and use it in existing code.
>
> > Yeah, but when we generate memcpy there might not be a way to
> > store the ctz info until RTL expansion where the magic should really happen ...
>
> True. It can be recovered without much difficulty in the cases I've
> looked at, but it could be lost in others.
>
> > So I'd say go for improving RTL expansion.
>
> 'k, thanks
>
> --
> Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/
> Free Software Activist GNU Toolchain Engineer
> Vim, Vi, Voltei pro Emacs -- GNUlius Caesar
next prev parent reply other threads:[~2021-02-05 8:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 12:40 Alexandre Oliva
2021-01-27 15:12 ` Richard Biener
2021-01-28 5:28 ` Alexandre Oliva
2021-01-28 8:59 ` Richard Biener
2021-02-02 17:13 ` Alexandre Oliva
2021-02-03 8:59 ` Richard Biener
2021-02-03 15:11 ` Alexandre Oliva
2021-02-04 8:37 ` Richard Biener
2021-02-04 22:17 ` Alexandre Oliva
2021-02-05 8:02 ` Richard Biener [this message]
2021-02-11 10:19 ` Alexandre Oliva
2021-02-11 12:14 ` Alexandre Oliva
2021-02-12 11:34 ` Richard Biener
2021-02-16 4:56 ` Alexandre Oliva
2021-02-16 10:47 ` Alexandre Oliva
2021-02-16 12:11 ` Richard Biener
2021-02-19 8:08 ` [PR94092] " Alexandre Oliva
2021-02-22 9:53 ` Richard Biener
2021-04-29 4:26 ` Alexandre Oliva
2021-04-30 14:42 ` Jeff Law
2021-05-03 8:55 ` Richard Biener
2021-05-04 1:59 ` Alexandre Oliva
2021-05-04 5:49 ` Prathamesh Kulkarni
2021-05-04 6:09 ` Alexandre Oliva
2021-02-05 0:13 ` Jim Wilson
2021-02-11 10:11 ` Alexandre Oliva
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=CAFiYyc1sx3XiFWGowvjJiT7RU_6aX0eVQHnJwT9crskEyDAQSA@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=oliva@adacore.com \
--cc=ook@ucw.cz \
/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).