public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Christophe Lyon <christophe.lyon@linaro.org>
To: Richard Biener <rguenther@suse.de>
Cc: Jakub Jelinek <jakub@redhat.com>, gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] phiopt: Simplify (X & Y) == X -> (X & ~Y) == 0 even in presence of integral conversions [PR94589]
Date: Wed, 19 May 2021 14:19:58 +0200	[thread overview]
Message-ID: <CAKdteOa9zMWVKBUDbd7i9ort3wD3hG_MjXLQiMsvbZhZehXamA@mail.gmail.com> (raw)
In-Reply-To: <CAKdteOZn28_3YH-7PZxwBcsFtfcKKDtzoQpkvPYha=99uCRJig@mail.gmail.com>

On Wed, 19 May 2021 at 13:29, Christophe Lyon
<christophe.lyon@linaro.org> wrote:
>
> On Wed, 19 May 2021 at 13:13, Richard Biener <rguenther@suse.de> wrote:
> >
> > On Wed, 19 May 2021, Jakub Jelinek wrote:
> >
> > > On Wed, May 19, 2021 at 11:09:19AM +0200, Jakub Jelinek via Gcc-patches wrote:
> > > > On Wed, May 19, 2021 at 10:15:53AM +0200, Christophe Lyon via Gcc-patches wrote:
> > > > > After this update, the test fails on arm and aarch64: according to the
> > > > > logs, the optimization is still performed 14 times.
> > > >
> > > > Seems this is because
> > > >               if (change
> > > >                   && !flag_syntax_only
> > > >                   && (load_extend_op (TYPE_MODE (TREE_TYPE (and0)))
> > > >                       == ZERO_EXTEND))
> > > >                 {
> > > >                   tree uns = unsigned_type_for (TREE_TYPE (and0));
> > > >                   and0 = fold_convert_loc (loc, uns, and0);
> > > >                   and1 = fold_convert_loc (loc, uns, and1);
> > > >                 }
> > > > in fold-const.c adds on these targets extra casts that prevent the
> > > > optimizations.
> > >
> > > This patch seems to fix it (but I don't have an easy way to test on aarch64
> > > or arm on the trunk and 11 branch would need numerous backports).
> >
> > OK if somebody manages to test on arm/aarch64.
> >
> I confirm it fixes the problem on arm. (aarch64 in progress)
>
And aarch64 is OK too.

> Thanks!
>
> > Richard.
> >
> > > 2021-05-19  Jakub Jelinek  <jakub@redhat.com>
> > >
> > >       PR tree-optimization/94589
> > >       * match.pd ((X & Y) == X -> (X & ~Y) == 0): Simplify even in presence
> > >       of integral conversions.
> > >
> > > --- gcc/match.pd.jj   2021-05-15 10:10:28.000000000 +0200
> > > +++ gcc/match.pd      2021-05-19 11:34:42.130624557 +0200
> > > @@ -4769,6 +4769,16 @@ (define_operator_list COND_TERNARY
> > >   (simplify
> > >    (cmp:c (bit_and:c @0 @1) @0)
> > >    (cmp (bit_and @0 (bit_not! @1)) { build_zero_cst (TREE_TYPE (@0)); }))
> > > + (simplify
> > > +  (cmp:c (convert@3 (bit_and (convert@2 @0) INTEGER_CST@1)) (convert @0))
> > > +  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
> > > +       && INTEGRAL_TYPE_P (TREE_TYPE (@2))
> > > +       && INTEGRAL_TYPE_P (TREE_TYPE (@3))
> > > +       && TYPE_PRECISION (TREE_TYPE (@2)) == TYPE_PRECISION (TREE_TYPE (@0))
> > > +       && TYPE_PRECISION (TREE_TYPE (@3)) > TYPE_PRECISION (TREE_TYPE (@2))
> > > +       && !wi::neg_p (wi::to_wide (@1)))
> > > +   (cmp (bit_and @0 (convert (bit_not @1)))
> > > +     { build_zero_cst (TREE_TYPE (@0)); })))
> > >
> > >   /* (X | Y) == Y becomes (X & ~Y) == 0.  */
> > >   (simplify
> > >
> > >
> > >       Jakub

      reply	other threads:[~2021-05-19 12:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18  7:42 [PATCH] phiopt: Optimize partial_ordering spaceship >= 0 -ffinite-math-only [PR94589] Jakub Jelinek
2021-05-18  7:55 ` Richard Biener
2021-05-19  8:15 ` Christophe Lyon
2021-05-19  9:09   ` Jakub Jelinek
2021-05-19  9:51     ` [PATCH] phiopt: Simplify (X & Y) == X -> (X & ~Y) == 0 even in presence of integral conversions [PR94589] Jakub Jelinek
2021-05-19 11:13       ` Richard Biener
2021-05-19 11:29         ` Christophe Lyon
2021-05-19 12:19           ` Christophe Lyon [this message]

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=CAKdteOa9zMWVKBUDbd7i9ort3wD3hG_MjXLQiMsvbZhZehXamA@mail.gmail.com \
    --to=christophe.lyon@linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=rguenther@suse.de \
    /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).