public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/97759] Could std::has_single_bit be faster? Date: Mon, 09 Nov 2020 10:44:23 +0000 [thread overview] Message-ID: <bug-97759-4-6zPjYAzzhe@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97759-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97759 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Looking at the referenced benchmark, options that would result in popcnt* instruction aren't there though and in the assembly it calls __popcountdi2. So, I guess we want at least: 1) for POPCOUNT (x) == 1 use x && (x & (x - 1)) == 0 if optab_handler (popcount_optab, mode) == CODE_FOR_nothing (a fuzzy case are the double-word cases where we'd end up with popcount (x >> wordbits) + popcount ((word) x) == 1 vs. double-word x && (x & (x - 1)) = 0) 2) the case Richi wrote about, optimize POPCOUNT (x) <= 1 or POPCOUNT (x) == 1 || x == 0 to (x & (x - 1)) == 0 always
next prev parent reply other threads:[~2020-11-09 10:44 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-09 0:01 [Bug libstdc++/97759] New: Could std::has_single_bit implementation " gcc-bugs at marehr dot dialup.fu-berlin.de 2020-11-09 5:41 ` [Bug libstdc++/97759] Could std::has_single_bit " tkoenig at gcc dot gnu.org 2020-11-09 8:16 ` rguenth at gcc dot gnu.org 2020-11-09 9:13 ` crazylht at gmail dot com 2020-11-09 10:44 ` jakub at gcc dot gnu.org [this message] 2020-11-09 11:00 ` jakub at gcc dot gnu.org 2020-11-09 11:13 ` redi at gcc dot gnu.org 2020-11-09 23:28 ` gcc-bugs at marehr dot dialup.fu-berlin.de 2020-11-09 23:28 ` gcc-bugs at marehr dot dialup.fu-berlin.de 2020-11-09 23:55 ` gcc-bugs at marehr dot dialup.fu-berlin.de 2020-11-10 0:16 ` gcc-bugs at marehr dot dialup.fu-berlin.de 2020-11-10 2:15 ` crazylht at gmail dot com 2020-11-10 8:57 ` redi at gcc dot gnu.org 2021-08-03 5:51 ` pinskia at gcc dot gnu.org 2022-03-03 11:08 ` peter at cordes dot ca 2024-03-04 22: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-97759-4-6zPjYAzzhe@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: linkBe 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).