Message ID | 20230430211248.761908-1-apinski@marvell.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2328882vqo; Sun, 30 Apr 2023 14:13:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xdaieYCxpbnY68ruMhKoTocjGdTWEewgGpEk20S+qZG+YGcVFRmg0z1BvyITcwC/2WTZL X-Received: by 2002:a17:906:db0d:b0:961:a67:28d with SMTP id xj13-20020a170906db0d00b009610a67028dmr8369035ejb.22.1682889226700; Sun, 30 Apr 2023 14:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682889226; cv=none; d=google.com; s=arc-20160816; b=sMnoHG+zVPpZbdTiNbewFSMfpmw3dSeHca5W3sPXiyE6BTIB4bTNwzpfHn9teZF89b 2sEsVHkL9UhfZ2Mx1qRp/awPI/Q+4T8HX9eid9qSxjYjUSPey7vltuVmdDU2/SPVphsN olm8yUAr+dS5ZbRgTPR5xXD9zrcrjYsRJX8SrsEvGQwQFb5llnOzKv85NRkW67op++M5 GjH0t6241oL1ehQh4Vz7kDuHaNl5MiRjhcnQf/IYr0WZ0C2/chWSwW/Nj+Sv0V6XPLvr ihuOtkXdnQBtDLOTHBylogpPWYVA5aZ2sbpHAvUlqHf8cXg6XMG3OwoGWK9cNKTgFEwq PGBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=GqZ6QuHW7MKi1MxTPOeA2kaUvOWEFxvvsMmnvStsQQ0=; b=yK8HfSV+KS4uXVg663vEJ5hTOmLWn+nIa0Q3dX1Y7WwQ2RjdKqEXQi03fQ5pEiNHl0 eSs4vMm7jpaSSMjIOM0Jx8C8XnmNeEKw8gUdBwltF8Nz/VhA81mnH/fC/0qEuSCv4TWT bwpBZGOHMCoyUSzf5Lu8iQTMpah0JlW3Ha7Pl/5MUmv7G3+RXWbH4AfT8xajLF1k7u9W T9VWikAT5sTiAdNV0N6vGYd9K3A9KHHuLvp9TRMun3U6RUnFxqARTNpOoyMSWh+6R3wj v0Yv4mf34v04nUBKlPpJ6K7MCw4U6L8sqlGwamb6DrGx2hjh8J7+kNtbpByvXco1M4Zx 3s4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MSUxQA6G; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n24-20020a05640206d800b005021cf63eacsi18765433edy.265.2023.04.30.14.13.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 14:13:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MSUxQA6G; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93D8E3858416 for <ouuuleilei@gmail.com>; Sun, 30 Apr 2023 21:13:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93D8E3858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682889225; bh=GqZ6QuHW7MKi1MxTPOeA2kaUvOWEFxvvsMmnvStsQQ0=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=MSUxQA6GCqkjbjCxhgs6/C6ttx1eQdi5UkwRNSXSGTE5qIeKbjfpa1y3p0yAktIZK ZJiUamxjyqt0IT8fn8lxHlMkzUykAgP2VUqSow4DK4u4Q9XIPgMkcbrgcIDv3jiJeS ubjtY4W/zHScnUuchg0R94x4kcWi+tGNhT4RATzA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 2CB0C3858D35 for <gcc-patches@gcc.gnu.org>; Sun, 30 Apr 2023 21:12:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2CB0C3858D35 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33UKr9ik028608 for <gcc-patches@gcc.gnu.org>; Sun, 30 Apr 2023 14:12:57 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3q92rnubnd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Sun, 30 Apr 2023 14:12:57 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 30 Apr 2023 14:12:55 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Sun, 30 Apr 2023 14:12:55 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id D76213F70AA; Sun, 30 Apr 2023 14:12:54 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> CC: Andrew Pinski <apinski@marvell.com> Subject: [PATCH] MATCH: Port CLRSB part of builtin_zero_pattern Date: Sun, 30 Apr 2023 14:12:48 -0700 Message-ID: <20230430211248.761908-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: cx53SIO5Rpz98q_c0CCA80HGcMnrbhMR X-Proofpoint-GUID: cx53SIO5Rpz98q_c0CCA80HGcMnrbhMR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-30_08,2023-04-27_01,2023-02-09_01 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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: Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Andrew Pinski <apinski@marvell.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764637253707758005?= X-GMAIL-MSGID: =?utf-8?q?1764637253707758005?= |
Series |
MATCH: Port CLRSB part of builtin_zero_pattern
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Andrew Pinski
April 30, 2023, 9:12 p.m. UTC
This ports the clrsb builtin part of builtin_zero_pattern to match.pd. A simple pattern to port. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * match.pd (a != 0 ? CLRSB(a) : CST -> CLRSB(a)): New pattern. --- gcc/match.pd | 8 ++++++++ 1 file changed, 8 insertions(+)
Comments
On Sun, Apr 30, 2023 at 11:13 PM Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > This ports the clrsb builtin part of builtin_zero_pattern > to match.pd. A simple pattern to port. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > gcc/ChangeLog: > > * match.pd (a != 0 ? CLRSB(a) : CST -> CLRSB(a)): New > pattern. > --- > gcc/match.pd | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/gcc/match.pd b/gcc/match.pd > index 0e782cde71d..bf918ba70ce 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -7787,6 +7787,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (cond (ne @0 integer_zerop@1) (func@4 (convert? @2)) integer_zerop@3) > @4)) > > +/* a != 0 ? FUN(a) : CST -> Fun(a) for some CLRSB builtins > + where CST is precision-1. */ > +(for func (CLRSB) > + (simplify > + (cond (ne @0 integer_zerop@1) (func@5 (convert?@4 @2)) INTEGER_CST@3) As you don't seem to use @2 why not match (func@5 @4) only? Otherwise LGTM. > + (if (wi::to_widest (@3) == TYPE_PRECISION (TREE_TYPE (@4)) - 1) > + @5))) > + > #if GIMPLE > /* a != 0 ? CLZ(a) : CST -> .CLZ(a) where CST is the result of the internal function for 0. */ > (for func (CLZ) > -- > 2.31.1 >
On Tue, May 2, 2023 at 5:24 AM Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Sun, Apr 30, 2023 at 11:13 PM Andrew Pinski via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > This ports the clrsb builtin part of builtin_zero_pattern > > to match.pd. A simple pattern to port. > > > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > > > gcc/ChangeLog: > > > > * match.pd (a != 0 ? CLRSB(a) : CST -> CLRSB(a)): New > > pattern. > > --- > > gcc/match.pd | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/gcc/match.pd b/gcc/match.pd > > index 0e782cde71d..bf918ba70ce 100644 > > --- a/gcc/match.pd > > +++ b/gcc/match.pd > > @@ -7787,6 +7787,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > > (cond (ne @0 integer_zerop@1) (func@4 (convert? @2)) integer_zerop@3) > > @4)) > > > > +/* a != 0 ? FUN(a) : CST -> Fun(a) for some CLRSB builtins > > + where CST is precision-1. */ > > +(for func (CLRSB) > > + (simplify > > + (cond (ne @0 integer_zerop@1) (func@5 (convert?@4 @2)) INTEGER_CST@3) > > As you don't seem to use @2 why not match (func@5 @4) only? Thanks for catching this, @2 should really have been @0, otherwise we get the wrong answer in general. I fixed the other patterns I just added for this same issue too. This is what I committed instead: /* a != 0 ? FUN(a) : CST -> Fun(a) for some CLRSB builtins where CST is precision-1. */ (for func (CLRSB) (simplify (cond (ne @0 integer_zerop@1) (func@4 (convert?@3 @0)) INTEGER_CST@2) (if (wi::to_widest (@2) == TYPE_PRECISION (TREE_TYPE (@3)) - 1) @4))) Thanks, Andrew > > Otherwise LGTM. > > > + (if (wi::to_widest (@3) == TYPE_PRECISION (TREE_TYPE (@4)) - 1) > > + @5))) > > + > > #if GIMPLE > > /* a != 0 ? CLZ(a) : CST -> .CLZ(a) where CST is the result of the internal function for 0. */ > > (for func (CLZ) > > -- > > 2.31.1 > >
diff --git a/gcc/match.pd b/gcc/match.pd index 0e782cde71d..bf918ba70ce 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7787,6 +7787,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cond (ne @0 integer_zerop@1) (func@4 (convert? @2)) integer_zerop@3) @4)) +/* a != 0 ? FUN(a) : CST -> Fun(a) for some CLRSB builtins + where CST is precision-1. */ +(for func (CLRSB) + (simplify + (cond (ne @0 integer_zerop@1) (func@5 (convert?@4 @2)) INTEGER_CST@3) + (if (wi::to_widest (@3) == TYPE_PRECISION (TREE_TYPE (@4)) - 1) + @5))) + #if GIMPLE /* a != 0 ? CLZ(a) : CST -> .CLZ(a) where CST is the result of the internal function for 0. */ (for func (CLZ)