public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Navid Rahimi <navidrahimi@microsoft.com>,
	Richard Biener <rguenther@suse.de>,
	Jeff Law <jeffreyalaw@gmail.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [EXTERNAL] [PATCH] testsuite: Fix up tree-ssa/pr103514.c testcase [PR103514]
Date: Mon, 31 Jan 2022 21:31:43 -0800	[thread overview]
Message-ID: <CA+=Sn1mhZUD4nrP0SpAmqDPjrR=NA4C73k8J6FRThgTct1OoQA@mail.gmail.com> (raw)
In-Reply-To: <20220131101249.GI2646553@tucnak>

On Mon, Jan 31, 2022 at 2:13 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Sun, Jan 30, 2022 at 10:16:44AM +0000, Navid Rahimi via Gcc-patches wrote:
> > Thanks Jakob for the correction. Sadly, I didn’t have any access to any non x86 architecture. But x86 was fully tested and there was no regression.
> >
> > In my spare time I will look at implementation of this for short-circuit targets.
>
> Note, it isn't just about those targets.
> If you write the code as:
> _Bool
> g (_Bool a, _Bool b)
> {
>   _Bool c;
>   if (!a)
>     c = 0;
>   else if (!b)
>     c = 0;
>   else
>     c = 1;
>   return c == (a ^ b);
> }
> instead, it will not match either, not even on x86, even when it is
> equivalent.
>
> Though, maybe for non-short-circuiting targets we should recognize this
> somewhere and turn into c = a & b;
>
> Since phiopt2 it is:
>   <bb 2> [local count: 1073741824]:
>   if (a_4(D) != 0)
>     goto <bb 3>; [50.00%]
>   else
>     goto <bb 4>; [50.00%]
>
>   <bb 3> [local count: 536870913]:
>   _8 = (int) b_5(D);
>
>   <bb 4> [local count: 1073741824]:
>   # iftmp.0_3 = PHI <_8(3), 0(2)>
> and phiopt3 makes
>   <bb 2> [local count: 1073741824]:
>   if (a_4(D) != 0)
>     goto <bb 3>; [50.00%]
>   else
>     goto <bb 4>; [50.00%]
>
>   <bb 3> [local count: 536870913]:
>
>   <bb 4> [local count: 1073741824]:
>   # _9 = PHI <b_5(D)(3), 0(2)>
>   iftmp.0_3 = (int) _9;
> out of that.
>
> CCing Andrew if he'd like to have a look for GCC 13.

Yes I have a patch to recognize:
  if (a_3(D) != 0)
    goto <bb 4>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870912]:

  <bb 4> [local count: 1073741824]:
  # c_2 = PHI <0(3), b_4(D)(2)>

already (a ? b : 0) into a & b.

This is already recorded as PR 89263.

Thanks,
Andrew Pinski

>
>         Jakub
>

  reply	other threads:[~2022-02-01  5:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 20:12 [PATCH] tree-optimization/103514 Missing XOR-EQ-AND Optimization Navid Rahimi
2022-01-28 22:14 ` Jeff Law
2022-01-29 16:46   ` [PATCH] testsuite: Fix up tree-ssa/pr103514.c testcase [PR103514] Jakub Jelinek
2022-01-30 10:16     ` [EXTERNAL] " Navid Rahimi
2022-01-31 10:12       ` Jakub Jelinek
2022-02-01  5:31         ` Andrew Pinski [this message]
2022-01-31  8:30     ` 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='CA+=Sn1mhZUD4nrP0SpAmqDPjrR=NA4C73k8J6FRThgTct1OoQA@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jeffreyalaw@gmail.com \
    --cc=navidrahimi@microsoft.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).