From patchwork Sun Apr 30 21:12:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 88955 Return-Path: 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 (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 ; 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 ; 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 ; 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 ; 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: CC: Andrew Pinski 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764637253707758005?= X-GMAIL-MSGID: =?utf-8?q?1764637253707758005?= 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) + (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)