From: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: Optimize combination of comparisons to dec+compare
Date: Tue, 15 Dec 2020 22:05:49 +0000 [thread overview]
Message-ID: <BYAPR21MB13514E4DB92C40207E8496A491C61@BYAPR21MB1351.namprd21.prod.outlook.com> (raw)
Richard,
> Do we already handle x < y || x <= CST to x <= y - CST?
That is an invalid transformation: e.g., consider x=3, y=4, CST=2.
Can you please clarify?
Thanks,
Eugene
-----Original Message-----
From: Richard Biener <richard.guenther@gmail.com>
Sent: Thursday, December 10, 2020 12:21 AM
To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Optimize combination of comparisons to dec+compare
On Thu, Dec 10, 2020 at 1:52 AM Eugene Rozenfeld via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> This patch adds a pattern for optimizing x < y || x == XXX_MIN to x <=
> y-1 if y is an integer with TYPE_OVERFLOW_WRAPS.
Do we already handle x < y || x <= CST to x <= y - CST?
That is, the XXX_MIN case is just a special-case of generic anti-range testing? For anti-range testing with signed types we pun to unsigned when possible.
> This fixes pr96674.
>
> Tested on x86_64-pc-linux-gnu.
>
> For this function
>
> bool f(unsigned a, unsigned b)
> {
> return (b == 0) | (a < b);
> }
>
> the code without the patch is
>
> test esi,esi
> sete al
> cmp esi,edi
> seta dl
> or eax,edx
> ret
>
> the code with the patch is
>
> sub esi,0x1
> cmp esi,edi
> setae al
> ret
>
> Eugene
>
> gcc/
> PR tree-optimization/96674
> * match.pd: New pattern x < y || x == XXX_MIN --> x <= y - 1
>
> gcc/testsuite
> * gcc.dg/pr96674.c: New test.
>
next reply other threads:[~2020-12-15 22:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 22:05 Eugene Rozenfeld [this message]
2020-12-22 23:01 ` Eugene Rozenfeld
-- strict thread matches above, loose matches on Subject: below --
2020-12-10 0:51 Eugene Rozenfeld
2020-12-10 8:21 ` 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=BYAPR21MB13514E4DB92C40207E8496A491C61@BYAPR21MB1351.namprd21.prod.outlook.com \
--to=eugene.rozenfeld@microsoft.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@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).