public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wilco 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 16:32:26 +0000	[thread overview]
Message-ID: <bug-90838-4-oSQHg9EC3m@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 #21 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Gabriel Ravier from comment #19)

> If the original code being branchless makes it faster, wouldn't that imply
> that we should use the table-based implementation when generating code for
> `__builtin_ctz` ?

__builtin_ctz is 3-4 times faster than the table implementation, so this
optimization is always worth it. This is why I believe the current situation is
not ideal since various targets still set CTZ_DEFINED_VALUE_AT_ZERO to 0 or 1.
One option would be to always allow it in Gimple (perhaps add an extra argument
for the value to return for a zero input), and at expand time check whether the
backend supports the requested value. It it doesn't, emit branches.

      parent reply	other threads:[~2023-02-17 16:32 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
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 [this message]

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-oSQHg9EC3m@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).