public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Navid Rahimi <navidrahimi@microsoft.com>,
	Andrew Pinski <pinskia@gmail.com>
Cc: 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 11:12:49 +0100	[thread overview]
Message-ID: <20220131101249.GI2646553@tucnak> (raw)
In-Reply-To: <BN6PR21MB0162E23BA451ED75B5186455A3249@BN6PR21MB0162.namprd21.prod.outlook.com>

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.

	Jakub


  reply	other threads:[~2022-01-31 10:12 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 [this message]
2022-02-01  5:31         ` Andrew Pinski
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=20220131101249.GI2646553@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=navidrahimi@microsoft.com \
    --cc=pinskia@gmail.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).