From: Richard Biener <richard.guenther@gmail.com>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: Andrew Pinski <pinskia@gmail.com>, Drew Ross <drross@redhat.com>,
gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] match.pd: Implement missed optimization (x << c) >> c -> -(x & 1) [PR101955]
Date: Mon, 24 Jul 2023 09:16:24 +0200 [thread overview]
Message-ID: <CAFiYyc2PL=8wtAZXyikH6pMj5oVLkoBXYwLdgAAxDDdpOiTS4Q@mail.gmail.com> (raw)
In-Reply-To: <6acebf98-5165-2c0c-7dea-0c148b7034cd@gmail.com>
On Sat, Jul 22, 2023 at 8:09 AM Jeff Law via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
>
> On 7/21/23 11:27, Andrew Pinski via Gcc-patches wrote:
> > On Fri, Jul 21, 2023 at 8:09 AM Drew Ross via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >> Simplifies (x << c) >> c where x is a signed integral type of
> >> width >= int and c = precision(type) - 1 into -(x & 1). Tested successfully
> >> on x86_64 and x86 targets.
> >
> > Thinking about this some more, I think this should be handled in
> > expand rather than on the gimple level.
> > It is very much related to PR 110717 even. We are basically truncating
> > to a signed one bit integer and then sign extending that across the
> > whole code.
> But why defer it to expand? This idiom is going to generate a -1,0
> result which is definitely interesting from a further simplification
> standpoint.
It's not 'simpler' so it would be a canonicalization. We talked about
providing a SEXT_EXPR at some point (sign-extend from constant bit N).
Another canonicalization to existing ops would be
(convert (convert:sbool @0))
where sbool is a 1-bit precision signed type. I think that's a better
canonicalization
than -(x & 1)? For zero-extensions we canonicalize such a conversion sequence
to x & const-mask. For sign-extensions there's no single operation
representation.
Richard.
>
> Jeff
next prev parent reply other threads:[~2023-07-24 7:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 15:08 Drew Ross
2023-07-21 17:27 ` Andrew Pinski
2023-07-22 6:09 ` Jeff Law
2023-07-24 7:16 ` Richard Biener [this message]
2023-07-24 19:29 ` Drew Ross
2023-07-24 19:42 ` Jakub Jelinek
2023-07-25 6:54 ` Richard Biener
2023-07-25 19:25 ` Drew Ross
2023-07-25 19:43 ` Jakub Jelinek
2023-07-26 8:39 ` Richard Biener
2023-07-26 18:18 ` Drew Ross
2023-07-28 6:30 ` Richard Biener
2023-08-01 19:20 ` [PATCH] match.pd: Canonicalize (signed x << c) >> c [PR101955] Drew Ross
2023-08-01 21:36 ` Jakub Jelinek
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='CAFiYyc2PL=8wtAZXyikH6pMj5oVLkoBXYwLdgAAxDDdpOiTS4Q@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=drross@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=pinskia@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).