From: Jeff Law <jeffreyalaw@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] match.pd: Add bitwise and pattern [PR106243]
Date: Wed, 3 Aug 2022 16:39:42 -0600 [thread overview]
Message-ID: <527a41b9-92a1-e662-da89-3176b77524fe@gmail.com> (raw)
In-Reply-To: <CAAgBjMmJNQOnjgB3=MP+B3THOfy7Zs9eiZ4ijGN88YE2CNoyqg@mail.gmail.com>
On 8/3/2022 2:44 PM, Prathamesh Kulkarni via Gcc-patches wrote:
> On Thu, 4 Aug 2022 at 00:41, Sam Feifer via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>> This patch adds a new optimization to match.pd. The pattern, -x & 1,
>> now gets simplified to x & 1, reducing the number of instructions
>> produced.
> Hi Sam,
> No comments on patch, but wondering if we can similarly add another pattern to
> simplify abs(x) & 1 -> x & 1 ?
> Currently we don't appear to do it on GIMPLE:
>
> __attribute__((noipa))
> int f1 (int x)
> {
> return __builtin_abs (x) & 1;
> }
>
> .optimized dump shows:
> _1 = ABS_EXPR <x_2(D)>;
> _3 = _1 & 1;
> return _3;
>
> altho combine simplifies it to x & 1 on RTL, resulting in code-gen:
> f1:
> and w0, w0, 1
> ret
Doesn't the abs(x) & mask simplify to x & mask for any mask where the
sign bit of x is off -- including cases where mask isn't necessarily a
compile-time constant, but we have range data which allows us to know
that x's sign bit is off in mask.
jeff
next prev parent reply other threads:[~2022-08-03 22:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 19:10 Sam Feifer
2022-08-03 20:44 ` Prathamesh Kulkarni
2022-08-03 22:39 ` Jeff Law [this message]
2022-08-04 7:08 ` Richard Biener
2022-08-04 12:34 ` Michael Matz
2022-08-04 7:06 ` Richard Biener
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=527a41b9-92a1-e662-da89-3176b77524fe@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/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).