From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=marvell.com 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=GqZ6QuHW7MKi1MxTPOeA2kaUvOWEFxvvsMmnvStsQQ0=; b=NVqFk4F/vIMlFtpqU6VaPzKYpLFxUySeWFsl4fWGVnAzQ01W7Tl8qTRA2Xv96u/Vy6uH TzOAzf6PMJX/pf3QnA9cAq3kng35AlKChaJdU4hfa3Fp8uu6bwUOg5ZpQ/Z2bTPatgpE y7kHd01OqVBvfpUGWBkpaTO5w5kqLMXE3uUhXzNKQ9SOgEdolQeVbZi832ErDN9s9ax7 gxyGaAy58PmCnzTpgYHynOS/0ilDL8+Yi8kmggKQBqYc0EPOMtJHy1Wa8PtjCeoh8Ogf phxsUcFh8uTOEJZJoV9S7xtDB80SU7yUq16it+vGhhxumMKV2Do+PD11h8Sh+R+bAreG bQ== 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) From: Andrew Pinski 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 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 List-Id: 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) -- 2.31.1