Message ID | ZEF4qvhBzBOEQxX1@tucnak |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DC463857700 for <patchwork@sourceware.org>; Thu, 20 Apr 2023 17:39:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DC463857700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682012394; bh=Uri8O3IEowTQMkQDNMIWxfH7v7sls9Wu3wP6z7NifcQ=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Sxy3yMkH9KzQShh8jO5xvlulKlhV68ksdEnXotkiMBoCFnOJ1wHotS/Qulm67G4qc BWjq5O0MD6H8bcM3tWS9/zWrHKQsrB6uhlgMBC5zA773J75asXkV756+CAA+71YrLA 1+DpXgmG7aCh5tsOvve1W8VVU7jv13Aqtv6EYup4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A1FA23858D37 for <gcc-patches@gcc.gnu.org>; Thu, 20 Apr 2023 17:39:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1FA23858D37 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-85-qiWE_RN5OTi6IIgaifagLA-1; Thu, 20 Apr 2023 13:39:22 -0400 X-MC-Unique: qiWE_RN5OTi6IIgaifagLA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A843A3C106A7; Thu, 20 Apr 2023 17:39:21 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45E691121315; Thu, 20 Apr 2023 17:39:20 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 33KHcuKv4184260 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 19:39:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 33KHcpvc4184259; Thu, 20 Apr 2023 19:38:51 +0200 Date: Thu, 20 Apr 2023 19:38:50 +0200 To: Richard Biener <rguenther@suse.de> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-vect-patterns: One small vect_recog_ctz_ffs_pattern tweak [PR109011] Message-ID: <ZEF4qvhBzBOEQxX1@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
tree-vect-patterns: One small vect_recog_ctz_ffs_pattern tweak [PR109011]
|
|
Commit Message
Jakub Jelinek
April 20, 2023, 5:38 p.m. UTC
Hi! 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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 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). Jakub
Comments
> Am 20.04.2023 um 19:40 schrieb Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org>: > > Hi! > > 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. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok > 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). > > --- gcc/tree-vect-patterns.cc.jj 2023-04-20 11:55:03.576154120 +0200 > +++ gcc/tree-vect-patterns.cc 2023-04-20 12:09:17.884633795 +0200 > @@ -1630,7 +1630,7 @@ vect_recog_ctz_ffs_pattern (vec_info *vi > && 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). */ > > Jakub >
--- gcc/tree-vect-patterns.cc.jj 2023-04-20 11:55:03.576154120 +0200 +++ gcc/tree-vect-patterns.cc 2023-04-20 12:09:17.884633795 +0200 @@ -1630,7 +1630,7 @@ vect_recog_ctz_ffs_pattern (vec_info *vi && 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). */