public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-121] tree-vect-patterns: One small vect_recog_ctz_ffs_pattern tweak [PR109011]
Date: Thu, 20 Apr 2023 17:45:42 +0000 (GMT)	[thread overview]
Message-ID: <20230420174542.4B9093858422@sourceware.org> (raw)

https://gcc.gnu.org/g:87c9bae4e32b54829dce0a93ff735412d5f684f8

commit r14-121-g87c9bae4e32b54829dce0a93ff735412d5f684f8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Apr 20 19:44:27 2023 +0200

    tree-vect-patterns: One small vect_recog_ctz_ffs_pattern tweak [PR109011]
    
    I've noticed I've made a typo, ifn in this function this late
    is always only IFN_CTZ or IFN_FFS, never IFN_CLZ.
    
    Due to this typo, we weren't using the originally intended
    .CTZ (X) = .POPCOUNT ((X - 1) & ~X)
    but
    .CTZ (X) = PREC - .POPCOUNT (X | -X)
    instead when we want to emit __builtin_ctz*/.CTZ using .POPCOUNT.
    Both compute the same value, both are defined at 0 with the
    same value (PREC), both have same number of GIMPLE statements,
    but I think the former ought to be preferred, because lots of targets
    have andn as a single operation rather than two, and also putting
    a -1 constant into a vector register is often cheaper than vector
    with broadcast PREC power of two value.
    
    2023-04-20  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/109011
            * tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern): Use
            .CTZ (X) = .POPCOUNT ((X - 1) & ~X) in preference to
            .CTZ (X) = PREC - .POPCOUNT (X | -X).

Diff:
---
 gcc/tree-vect-patterns.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index d1b86e8b5e0..a49b0953977 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -1630,7 +1630,7 @@ vect_recog_ctz_ffs_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo,
        && defined_at_zero_new
        && val == prec
        && val_new == prec)
-      || (ifnnew == IFN_POPCOUNT && ifn == IFN_CLZ))
+      || (ifnnew == IFN_POPCOUNT && ifn == IFN_CTZ))
     {
       /* .CTZ (X) = PREC - .CLZ ((X - 1) & ~X)
 	 .CTZ (X) = .POPCOUNT ((X - 1) & ~X).  */

                 reply	other threads:[~2023-04-20 17:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230420174542.4B9093858422@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@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).