public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109011] missed optimization in presence of __builtin_ctz
Date: Thu, 20 Apr 2023 09:56:13 +0000	[thread overview]
Message-ID: <bug-109011-4-4cv20hAptH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109011-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:705b0d2b62318b3935214f08a1cf023b1117acb8

commit r14-108-g705b0d2b62318b3935214f08a1cf023b1117acb8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Apr 20 11:55:16 2023 +0200

    tree-vect-patterns: Pattern recognize ctz or ffs using clz, popcount or ctz
[PR109011]

    The following patch allows to vectorize __builtin_ffs*/.FFS even if
    we just have vector .CTZ support, or
__builtin_ffs*/.FFS/__builtin_ctz*/.CTZ
    if we just have vector .CLZ or .POPCOUNT support.
    It uses various expansions from Hacker's Delight book as well as GCC's
    expansion, in particular:
    .CTZ (X) = PREC - .CLZ ((X - 1) & ~X)
    .CTZ (X) = .POPCOUNT ((X - 1) & ~X)
    .CTZ (X) = (PREC - 1) - .CLZ (X & -X)
    .FFS (X) = PREC - .CLZ (X & -X)
    .CTZ (X) = PREC - .POPCOUNT (X | -X)
    .FFS (X) = (PREC + 1) - .POPCOUNT (X | -X)
    .FFS (X) = .CTZ (X) + 1
    where the first one can be only used if both CTZ and CLZ have value
    defined at zero (kind 2) and both have value of PREC there.
    If the original has value defined at zero and the latter doesn't
    for other forms or if it doesn't have matching value for that case,
    a COND_EXPR is added for that afterwards.

    The patch also modifies vect_recog_popcount_clz_ctz_ffs_pattern
    such that the two can work together.

    2023-04-20  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/109011
            * tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern): New function.
            (vect_recog_popcount_clz_ctz_ffs_pattern): Move
vect_pattern_detected
            call later.  Don't punt for IFN_CTZ or IFN_FFS if it doesn't have
            direct optab support, but has instead IFN_CLZ, IFN_POPCOUNT or
            for IFN_FFS IFN_CTZ support, use vect_recog_ctz_ffs_pattern for
that
            case.
            (vect_vect_recog_func_ptrs): Add ctz_ffs entry.

            * gcc.dg/vect/pr109011-1.c: Remove -mpower9-vector from
            dg-additional-options.
            (baz, qux): Remove functions and corresponding dg-final.
            * gcc.dg/vect/pr109011-2.c: New test.
            * gcc.dg/vect/pr109011-3.c: New test.
            * gcc.dg/vect/pr109011-4.c: New test.
            * gcc.dg/vect/pr109011-5.c: New test.

  parent reply	other threads:[~2023-04-20  9:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 14:56 [Bug tree-optimization/109011] New: " vincenzo.innocente at cern dot ch
2023-03-03 19:45 ` [Bug tree-optimization/109011] " pinskia at gcc dot gnu.org
2023-03-03 19:48 ` pinskia at gcc dot gnu.org
2023-03-03 20:21 ` jakub at gcc dot gnu.org
2023-03-03 20:39 ` jakub at gcc dot gnu.org
2023-03-03 20:46 ` jakub at gcc dot gnu.org
2023-03-04  0:18 ` jakub at gcc dot gnu.org
2023-03-04 11:14 ` jakub at gcc dot gnu.org
2023-03-04 12:22 ` jakub at gcc dot gnu.org
2023-03-04 14:01 ` jakub at gcc dot gnu.org
2023-03-04 15:08 ` jakub at gcc dot gnu.org
2023-03-06  5:26 ` crazylht at gmail dot com
2023-03-06  7:01 ` jakub at gcc dot gnu.org
2023-03-06  7:59 ` crazylht at gmail dot com
2023-03-06  8:11 ` jakub at gcc dot gnu.org
2023-03-06  8:23 ` crazylht at gmail dot com
2023-03-06  8:32 ` jakub at gcc dot gnu.org
2023-03-06  9:22 ` jakub at gcc dot gnu.org
2023-03-14  9:24 ` crazylht at gmail dot com
2023-03-16  6:32 ` crazylht at gmail dot com
2023-04-19  9:15 ` cvs-commit at gcc dot gnu.org
2023-04-20  9:56 ` cvs-commit at gcc dot gnu.org [this message]
2023-04-20 17:45 ` cvs-commit at gcc dot gnu.org
2023-04-24  1:35 ` cvs-commit 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-109011-4-4cv20hAptH@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).