From patchwork Thu Aug 18 22:03:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp553260pxh; Thu, 18 Aug 2022 15:07:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR49gLbN59FPY2XnBx00OjAznPi0aciY0v/kyt9LvFZgf4cS5MsCnhbl9+e48UbdYiMn6SVq X-Received: by 2002:a05:6402:26cb:b0:43e:6fab:11c6 with SMTP id x11-20020a05640226cb00b0043e6fab11c6mr3619532edd.272.1660860457726; Thu, 18 Aug 2022 15:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660860457; cv=none; d=google.com; s=arc-20160816; b=st/Nx6P3OCibYwbE69TT5+sRk9pIltNJsw2pfel4e/U0B/dQOxZ1GltvVLJX3aJa2t TMxHwvLp1cE6A08ZlVvCuU23m4GvhemvOFyjGHaEfdU8gYMwY7YW39RJp0J+21scnBAg AXLHgzojaAGXuu2PBuIVnV6nyELO5FoBEvPOFXkjrvopq9k9fdt2ca8dWiphtRM426P/ NfaPx/HAVhBYbsly/JYCM0FVudsBOqUBtLLW5nq+M93VVYRryXd39OegCOtw32Ar2mWW YG6uhpBua2JcJmcCFUZoSa79Ep0BaDoqVQM//dIUbTLipbfOpTNpnPLQKeyJ8IJ0bX2P ESpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=jcHsO5t2ncH2gU2uk0LwBigR/hMVBHBp4DBYPevSOfg=; b=sXe3Xv+Cj83YQ/o3T4P3oh0OD4OQ5+roJd9SiIb9at93H18yxgyCcmtWkr7dETQXLd frr0H5P06iJNIYRxzZsfK5LYeVoG5CShSRYiS0x2230YIDGd9+vO58urSG21By/wFG4G lw05802Z7qNvFspE9ROC1kSryNsn+lMeWspsiUk7vXAmvscryj+/EoUZ7K7nXm1qtfyU dMQoIvhs6clhAn9wHhdWHgiSZ//fWtZXjcJ6ADzS8TozC0EQQ30qVId4fGNHyPmlHxIU KX8mreAPQ46lyQKOVSLzGHYNmqBfVJ9J13nTFX/waByyt42YBjWw5dKvFzmIAyeG3AYE VFLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="d/7x7FUk"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sa14-20020a1709076d0e00b007308e7cd167si1725558ejc.846.2022.08.18.15.07.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 15:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="d/7x7FUk"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 A869E385741C for ; Thu, 18 Aug 2022 22:06:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A869E385741C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660860401; bh=jcHsO5t2ncH2gU2uk0LwBigR/hMVBHBp4DBYPevSOfg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=d/7x7FUktGwZ46RwN5hlmR/3teNF7zJRZ2ry6Y1BrNT4KxnrAorVo34hgRGg2zWzn d3hXle28JgU/jO+g/0yKBxJXNKSBUZ7sUv7JbymWOXIJIyaED0wO8aicoMSj0eLB7Y tg1KtE6lXiiGXbPDbug2+K+UvTSHoaeder7DM9TU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 7D0EB3858294 for ; Thu, 18 Aug 2022 22:04:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D0EB3858294 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27IHqWrD002457 for ; Thu, 18 Aug 2022 15:04:04 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3j1t6r10wr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 Aug 2022 15:04:04 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 18 Aug 2022 15:04:03 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 18 Aug 2022 15:04:03 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id DCDC63F707D; Thu, 18 Aug 2022 15:04:02 -0700 (PDT) To: Subject: [PATCH 06/10] [RISCV] Use constraints/predicates instead of checking const_int directly for shNadd patterns Date: Thu, 18 Aug 2022 15:03:49 -0700 Message-ID: <1660860233-11175-7-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660860233-11175-1-git-send-email-apinski@marvell.com> References: <1660860233-11175-1-git-send-email-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: UeRTAP2V62vDaaMP3gI6J8MxVzWuIETm X-Proofpoint-GUID: UeRTAP2V62vDaaMP3gI6J8MxVzWuIETm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-18_16,2022-08-18_01,2022-06-22_01 X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: apinski--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: apinski@marvell.com Cc: 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?1741538415139466210?= X-GMAIL-MSGID: =?utf-8?q?1741538415139466210?= From: Andrew Pinski This simplifies the code by adding a predicate and a constraint for 1/2/3. The aarch64 backend has a similar predicate called aarch64_shift_imm_ which they use there. OK? Built and tested on riscv32-linux-gnu and riscv64-linux-gnu with no regressions. Thanks, Andrew Pinski gcc/ChangeLog: * config/riscv/constraints.md (Ds3): New constraint. * config/riscv/predicates.md (imm123_operand): New predicate. * config/riscv/bitmanip.md (*shNadd): Use Ds3 and imm123_operand. (*shNadduw): Likewise. --- gcc/config/riscv/bitmanip.md | 8 +++----- gcc/config/riscv/constraints.md | 6 ++++++ gcc/config/riscv/predicates.md | 5 +++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md index ebd6eee1a22..73a36f7751b 100644 --- a/gcc/config/riscv/bitmanip.md +++ b/gcc/config/riscv/bitmanip.md @@ -32,10 +32,9 @@ (define_insn "*zero_extendsidi2_bitmanip" (define_insn "*shNadd" [(set (match_operand:X 0 "register_operand" "=r") (plus:X (ashift:X (match_operand:X 1 "register_operand" "r") - (match_operand:QI 2 "immediate_operand" "I")) + (match_operand:QI 2 "imm123_operand" "Ds3")) (match_operand:X 3 "register_operand" "r")))] - "TARGET_ZBA - && (INTVAL (operands[2]) >= 1) && (INTVAL (operands[2]) <= 3)" + "TARGET_ZBA" "sh%2add\t%0,%1,%3" [(set_attr "type" "bitmanip") (set_attr "mode" "")]) @@ -44,11 +43,10 @@ (define_insn "*shNadduw" [(set (match_operand:DI 0 "register_operand" "=r") (plus:DI (and:DI (ashift:DI (match_operand:DI 1 "register_operand" "r") - (match_operand:QI 2 "immediate_operand" "I")) + (match_operand:QI 2 "imm123_operand" "Ds3")) (match_operand 3 "immediate_operand" "")) (match_operand:DI 4 "register_operand" "r")))] "TARGET_64BIT && TARGET_ZBA - && (INTVAL (operands[2]) >= 1) && (INTVAL (operands[2]) <= 3) && (INTVAL (operands[3]) >> INTVAL (operands[2])) == 0xffffffff" "sh%2add.uw\t%0,%1,%4" [(set_attr "type" "bitmanip") diff --git a/gcc/config/riscv/constraints.md b/gcc/config/riscv/constraints.md index bafa4188ccb..61b84875fd9 100644 --- a/gcc/config/riscv/constraints.md +++ b/gcc/config/riscv/constraints.md @@ -54,6 +54,12 @@ (define_constraint "L" (and (match_code "const_int") (match_test "LUI_OPERAND (ival)"))) +(define_constraint "Ds3" + "@internal + 1, 2 or 3 immediate" + (and (match_code "const_int") + (match_test "IN_RANGE (ival, 1, 3)"))) + ;; Floating-point constant +0.0, used for FCVT-based moves when FMV is ;; not available in RV32. (define_constraint "G" diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md index 79e0c1d5589..2af7f661d6f 100644 --- a/gcc/config/riscv/predicates.md +++ b/gcc/config/riscv/predicates.md @@ -244,6 +244,11 @@ (define_predicate "imm5_operand" (and (match_code "const_int") (match_test "INTVAL (op) < 5"))) +;; A const_int for sh1add/sh2add/sh3add +(define_predicate "imm123_operand" + (and (match_code "const_int") + (match_test "IN_RANGE (INTVAL (op), 1, 3)"))) + ;; A CONST_INT operand that consists of a single run of consecutive set bits. (define_predicate "consecutive_bits_operand" (match_code "const_int")