public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wdijkstr at arm dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/94026] combine missed opportunity to simplify comparisons with zero
Date: Fri, 20 Mar 2020 14:23:13 +0000 [thread overview]
Message-ID: <bug-94026-4-XTSSoth5gM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94026-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94026
Wilco <wdijkstr at arm dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wdijkstr at arm dot com
--- Comment #5 from Wilco <wdijkstr at arm dot com> ---
(In reply to Fei Yang from comment #4)
> (In reply to Fei Yang from comment #0)
> > Created attachment 47966 [details]
> > proposed patch to fix this issue
> >
> > Simple test case:
> > int
> > foo (int c, int d)
> > {
> > int a = (c >> d) & 7;
> >
> > if (a >= 2) {
> > return 1;
> > }
> >
> > return 0;
> > }
> >
> > Compile option: gcc -S -O2 test.c
> >
> >
> > On aarch64, GCC trunk emits 4 instrunctions:
> > asr w0, w0, 8
> > tst w0, 6
> > cset w0, ne
> > ret
> >
> > which can be further simplified into:
> > tst x0, 1536
> > cset w0, ne
> > ret
> >
> > We see the same issue on other targets such as i386 and x86-64.
> >
> > Attached please find proposed patch for this issue.
>
> The previously posted test case is not correct.
> Test case should be:
> int fifth (int c)
> {
> int a = (c >> 8) & 7;
>
> if (a >= 2) {
> return 1;
> } else {
> return 0;
> }
> }
Simpler cases are:
int f1(int x) { return ((x >> 8) & 6) != 0; }
int f2(int x) { return ((x << 2) & 24) != 0; }
int f3(unsigned x) { return ((x << 2) & 15) != 0; }
int f4(unsigned x) { return ((x >> 2) & 14) != 0; }
next prev parent reply other threads:[~2020-03-20 14:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-94026-4@http.gcc.gnu.org/bugzilla/>
2020-03-13 3:09 ` felix.yang at huawei dot com
2020-03-13 5:00 ` pinskia at gcc dot gnu.org
2020-03-16 3:34 ` felix.yang at huawei dot com
2020-03-20 14:23 ` wdijkstr at arm dot com [this message]
2021-07-25 1:14 ` [Bug tree-optimization/94026] " pinskia at gcc dot gnu.org
2022-06-24 15:48 ` segher at gcc dot gnu.org
2022-06-24 16:30 ` law at gcc dot gnu.org
2022-06-24 17:30 ` segher at gcc dot gnu.org
2022-06-24 18:07 ` segher at gcc dot gnu.org
2022-06-24 20:06 ` segher at gcc dot gnu.org
2022-06-27 6:45 ` cvs-commit at gcc dot gnu.org
2022-07-03 20:55 ` roger at nextmovesoftware dot com
2022-08-09 17:57 ` cvs-commit at gcc dot gnu.org
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=bug-94026-4-XTSSoth5gM@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@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).