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 middle-end/97738] Optimizing division by value & - value for HAKMEM 175 Date: Fri, 06 Nov 2020 18:27:29 +0000 [thread overview] Message-ID: <bug-97738-4-UW8Lfj6FyM@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97738-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97738 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> --- What about a version that still sets lowest_bit to value & -value; rather than 1 < ctz? Also, I'm not sure you can safely do the (changed_bits >> ctz) >> 2 to changed_bits >> (ctz + 2) transformation, while because of the division one can count on value not being 0 (otherwise UB), value & -value can still be e.g. 1U << 31 and then ctz 31 too, and changed_bits >> (31 + 2) being UB, while (changed_bits >> 31) >> 2 well defined returning 0. So, I think we could e.g. during expansion (or isel) based on target cost optimize x / (y & -y) to x >> __builtin_ctz (y) (also assuming the optab for ctz exists), but anything else looks complicated.
next prev parent reply other threads:[~2020-11-06 18:27 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-06 8:23 [Bug rtl-optimization/97738] New: " tkoenig at gcc dot gnu.org 2020-11-06 8:45 ` [Bug middle-end/97738] " rguenth at gcc dot gnu.org 2020-11-06 14:21 ` tkoenig at gcc dot gnu.org 2020-11-06 17:52 ` tkoenig at gcc dot gnu.org 2020-11-06 18:27 ` jakub at gcc dot gnu.org [this message] 2020-11-07 10:21 ` tkoenig at gcc dot gnu.org 2021-09-26 8:23 ` pinskia at gcc dot gnu.org 2021-09-26 8:24 ` 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-97738-4-UW8Lfj6FyM@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).