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/64992] More optimize opportunity
Date: Mon, 29 Nov 2021 03:51:03 +0000	[thread overview]
Message-ID: <bug-64992-4-kdu0Umd9Ix@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64992-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The missed optimization is:
int f(int c)
{
  unsigned t = c == 1;
  t <<= 1;
  return t == 0;
}

int f1(int c)
{
  unsigned t = c == 1;
  return ((int)t) <= 0;
}

That is (t << 1) == 0 should be convert into either:
(t & 0x7fffffff) or ((int)t) <= 0

Though the (semi more) general case is:
(for shift (lshift rshift)
 (for eqne (eq ne)
  (simplify
   (eqne (shift @0 INTEGER_CST@1) integer_zerop@2)
   (with
    {
      mask = ...
    }
    (eqne (bit_and @0 { mask; }) @2)))))

And then the mask bit_and neeq to gtle

And then the rest will just work

  parent reply	other threads:[~2021-11-29  3:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10  3:01 [Bug tree-optimization/64992] New: " ishiura-compiler at ml dot kwansei.ac.jp
2015-02-10 10:18 ` [Bug tree-optimization/64992] " rguenth at gcc dot gnu.org
2015-02-15  5:15 ` ishiura-compiler at ml dot kwansei.ac.jp
2015-02-15 23:32 ` ishiura-compiler at ml dot kwansei.ac.jp
2021-11-29  3:51 ` pinskia at gcc dot gnu.org [this message]
2021-11-30 22:08 ` pinskia at gcc dot gnu.org
2021-11-30 22:18 ` pinskia at gcc dot gnu.org
2021-12-01  5:53 ` pinskia at gcc dot gnu.org
2022-08-15 16:41 ` cvs-commit at gcc dot gnu.org
2022-09-10 21:10 ` roger at nextmovesoftware dot com

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-64992-4-kdu0Umd9Ix@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).