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/107053] ones bits is not tracked and popcount is not tracked
Date: Tue, 27 Sep 2022 15:40:29 +0000	[thread overview]
Message-ID: <bug-107053-4-O1Ryv04gHq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107053-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the correct testcase is:
void link_failure();
void f(int a)
{
    a |= 0x300;
    int b =  __builtin_popcount(a);
    if (b < 2)
        link_failure();
}

--- CUT ---
the range of b should be 2..31 (assuming int is 32bits).
With this change clang is able to optimize it.

For the original testcase I think it can be folded to:
void link_failure();
void f(int a)
{
    int a1 &= ~0x300;
    if (a1 != 0)
        link_failure();
}
but that might be worse unless popcount can be removed. (If I did this
correctly).

  parent reply	other threads:[~2022-09-27 15:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 15:24 [Bug tree-optimization/107053] New: " pinskia at gcc dot gnu.org
2022-09-27 15:24 ` [Bug tree-optimization/107053] " pinskia at gcc dot gnu.org
2022-09-27 15:33 ` aldyh at gcc dot gnu.org
2022-09-27 15:40 ` pinskia at gcc dot gnu.org [this message]
2022-09-28  6:28 ` aldyh at gcc dot gnu.org
2023-07-12 21:16 ` cvs-commit at gcc dot gnu.org
2023-07-12 21:18 ` aldyh at gcc dot gnu.org
2023-07-12 21:56 ` 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-107053-4-O1Ryv04gHq@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).