public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109960] [10/11/12/13/14 Regression] missing combining of `(a&1) != 0 || (a&2)!=0` into `(a&3)!=0`
Date: Thu, 25 May 2023 02:51:32 +0000	[thread overview]
Message-ID: <bug-109960-4-w53BXFbjns@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109960-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109960

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I happened to notice this because I am working on a match patch that transform
`a ? 1 : b` into `a | b`.

In the case of stmt_can_terminate_bb_p, I noticed we had:
  <bb 31> [local count: 330920071]:
  _48 = MEM[(const struct gasm *)t_22(D)].D.129035.D.128905.D.128890.subcode;
  _49 = _48 & 2;
  if (_49 != 0)
    goto <bb 33>; [34.00%]
  else
    goto <bb 32>; [66.00%]

  <bb 32> [local count: 218407246]:
  _50 = (bool) _48;

  <bb 33> [local count: 940291388]:
  # _13 = PHI <0(14), _50(32), _12(29), 0(11), 0(30), 1(2), 1(31), 0(25)>

And the patch to match would do:
  <bb 31> [local count: 330920071]:
  _48 = MEM[(const struct gasm *)t_22(D)].D.129035.D.128905.D.128890.subcode;
  _49 = _48 & 2;
  _50 = (bool) _48;
  _127 = _49 != 0;
  _44 = _50 | _127;

  <bb 32> [local count: 940291388]:
  # _13 = PHI <0(14), 0(25), _12(29), 0(11), 0(30), 1(2), _44(31)>

Which is definitely better than before but I was like isn't that the same as:
  _49 = _48 & 3;
  _44 = _49 != 0;

  parent reply	other threads:[~2023-05-25  2:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25  0:40 [Bug tree-optimization/109960] New: " pinskia at gcc dot gnu.org
2023-05-25  0:41 ` [Bug tree-optimization/109960] " pinskia at gcc dot gnu.org
2023-05-25  0:45 ` pinskia at gcc dot gnu.org
2023-05-25  0:58 ` pinskia at gcc dot gnu.org
2023-05-25  2:29 ` pinskia at gcc dot gnu.org
2023-05-25  2:51 ` pinskia at gcc dot gnu.org [this message]
2023-05-25  7:59 ` rguenth at gcc dot gnu.org
2023-07-07 10:45 ` [Bug tree-optimization/109960] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-09-16 22:55 ` pinskia at gcc dot gnu.org
2023-09-16 23:04 ` pinskia at gcc dot gnu.org
2023-09-17  1:27 ` pinskia at gcc dot gnu.org
2024-01-12 13:53 ` rguenth 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-109960-4-w53BXFbjns@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).