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/96923] Failure to optimize a select-related bool pattern to or+not
Date: Tue, 01 Jun 2021 23:19:05 +0000	[thread overview]
Message-ID: <bug-96923-4-pFQeDMxonR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96923-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> Created attachment 50905 [details]
> Patch which is in testing (needs testcases)
> 
> As I said for the case in this PR, it needs
> https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571616.html too.
> 
> If you change !b to b; that is "!a ? b : 0", this patch will optimize it. 
> The other patch is needed to allow to move !b out of the conditional.

This patch has one bug in it where we need a convert added.
BUT then we run into a different missed optimization issue.
  _51 = p2_22 <= prephitmp_122;
  _44 = (logical(kind=4)) _51;
  _37 = p2_22 > prephitmp_122;
  _49 = (logical(kind=4)) _37;
  _38 = _49 & found_p_63;
  _46 = _38 | _44;

This is really just:
_51 = p2_22 <= prephitmp_122;
_44 = (logical(kind=4)) _51;
_46 = found_p_63| _44;

That is we don't optimize:
(a & ~b) | b into a | b if ~b has been converted already.

The other thing I noticed is the cast should not be really needed but nothing
removes it; I will look at that later.

Note I could rewrite the pattern to do the simplification of the constants
manually but I want to try to avoid that.

  parent reply	other threads:[~2021-06-01 23:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 14:06 [Bug tree-optimization/96923] New: " gabravier at gmail dot com
2020-09-03 14:49 ` [Bug tree-optimization/96923] " gabravier at gmail dot com
2020-09-06 23:45 ` pinskia at gcc dot gnu.org
2020-09-06 23:47 ` pinskia at gcc dot gnu.org
2021-06-01 21:02 ` pinskia at gcc dot gnu.org
2021-06-01 21:40 ` pinskia at gcc dot gnu.org
2021-06-01 23:19 ` pinskia at gcc dot gnu.org [this message]
2021-06-01 23:49 ` pinskia at gcc dot gnu.org
2023-05-24  0:01 ` pinskia at gcc dot gnu.org
2023-07-31 17:14 ` pinskia 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-96923-4-pFQeDMxonR@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).