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 tree-optimization/90838] Detect table-based ctz implementation
Date: Fri, 17 Feb 2023 10:34:19 +0000	[thread overview]
Message-ID: <bug-90838-4-BM2zoOebKf@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-90838-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The patch does:
+      bool zero_ok = CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), ctzval) ==
2;
+
+      /* Skip if there is no value defined at zero, or if we can't easily
+        return the correct value for zero.  */
+      if (!zero_ok)
+       return false;
+      if (zero_val != ctzval && !(zero_val == 0 && ctzval == type_size))
+       return false;
For CTZ_DEFINED_VALUE_AT_ZERO == 1 we could support it the same way but we'd
need
to emit into the IL an equivalent of val == 0 ? zero_val : .CTZ (val) (with
GIMPLE_COND and a separate bb - not sure if anything in forwprop creates new
basic blocks right now), where there is a high chance that RTL opts would turn
it back into unconditional
ctz.
That still wouldn't help non--mbmi x86, because CTZ_DEFINED_VALUE_AT_ZERO is 0
there.
We could handle even that case by doing the branches around, but those would
stay there
in the generated code, at which point I wonder whether it would be a win.  The
original
code is branchless...

  parent reply	other threads:[~2023-02-17 10:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-90838-4@http.gcc.gnu.org/bugzilla/>
2019-06-11 22:47 ` wdijkstr at arm dot com
2023-02-17  2:20 ` gabravier at gmail dot com
2023-02-17  2:44 ` pinskia at gcc dot gnu.org
2023-02-17 10:34 ` jakub at gcc dot gnu.org [this message]
2023-02-17 12:57 ` wilco at gcc dot gnu.org
2023-02-17 13:03 ` jakub at gcc dot gnu.org
2023-02-17 14:27 ` wilco at gcc dot gnu.org
2023-02-17 14:33 ` jakub at gcc dot gnu.org
2023-02-17 14:41 ` gabravier at gmail dot com
2023-02-17 14:45 ` jakub at gcc dot gnu.org
2023-02-17 16:32 ` wilco 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-90838-4-BM2zoOebKf@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).