From patchwork Mon Jan 9 13:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 40867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2155953wrt; Mon, 9 Jan 2023 05:30:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXutfKil9NRYzLXgOneMsPufCNHIL1steN7zC5pfOH9oEFg8y1i3IXLWvhuCx9G23fvFpqyp X-Received: by 2002:a17:906:3f8b:b0:83f:b41a:2e9d with SMTP id b11-20020a1709063f8b00b0083fb41a2e9dmr58261478ejj.16.1673271004686; Mon, 09 Jan 2023 05:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673271004; cv=none; d=google.com; s=arc-20160816; b=EJzEe4oXPKw44a/7DwGjD6cqD6LB5/rByFhKBU0dB2YWeFYUsfEBEKWY5kwKC2325U iDNM+fSvPxxJihbB9QFmKACGGruhnIeDa0mTSXrt31ytqyvawEhi4B1tt6C6PkJ3HGIN 4maUVD2xAGs9hKQCtHdbcpnblB1XJ9/fHFxzrIDFgGrlmzTMF4VAqCoRFLcbfTVyE0x6 ZOR0UxGedojZsvTWa+jUzXQxY6KPYd9XUoWEy7XQToASZEen/G4qEyCYwGH5mJDjE11s SLAzqH2uAH8vgmgpZnN8M+kV31FI83LWNo9SrYuyqet+A4AsScO109eO8d4JZI+QS3Sr uWoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-language:thread-index :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=MXUyRTOmgGMk5DayDxEKRXrfDr7F+Ors0/5ig0C+YHM=; b=MdqFzMggIKF1+ldBqOrk720y0wJg1lKt5VQJHK9CTxoVic0awrEq/n1Du2FhuhRdjE giRUPZ/3WlaGEDzmDnyjh6nF5gHu/LZETL6fcJtObNqM48QP9bjYTdlTn2I+xpJauTVH 1zIA++z5UDtOeTiRi/DEY7AWyHj63mFF3YTFJmGIoywVeaR6Iud3AhX4WdfN/h4JT5o7 LLni4dh2fY/SM1Tf17/vAiIj802t3IWLYg3KLsSSQfE3ZNSrN7gj5mKNWfmZpMAb36Ge 1moBcbEG8pTp91SMrYV+2b1B2ziW5J3wlVLzob633gWTxsHLs1NjpeNT1YH1X0e5pYOr BqFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=GpcQJEDw; 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" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ho38-20020a1709070ea600b0084ce55f4b7csi10238345ejc.470.2023.01.09.05.30.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 05:30:04 -0800 (PST) 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=fail header.i=@nextmovesoftware.com header.s=default header.b=GpcQJEDw; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16ADB385B535 for ; Mon, 9 Jan 2023 13:29:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id DBC683858005 for ; Mon, 9 Jan 2023 13:29:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBC683858005 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MXUyRTOmgGMk5DayDxEKRXrfDr7F+Ors0/5ig0C+YHM=; b=GpcQJEDwRv6Vj0rUIM/c9FNwNO tFUjNMvEv3OXrn7aTGHPhD2kz2LiWnTXpEfIE73/N4lG908PvnjXGk+J5HfWF325f42VKrQPWMRCU /OWYSAs5SHU8L8Vwz2EUJU9bqBJsBiBbLwokhbIjKGYJZnz1WqPBe8RNSeM/ezZqtXA4+QNJ6xg/8 t02nGq/8RMG4/VU7yr42fOiwcU5lWHNfpDp3AUjENnQlAKKHvp4qbjtfhvpun10N4Ez9WcrcJ/5pE juAdVGXPmTaAgv97/gX1gdvPTOYSbBB62k70QzfPWxof+GV6jyRsEzYdcZ2az6WJ9Hvv3sEEBjIoF jWFCexUw==; Received: from [185.62.158.67] (port=58359 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pEsDF-00088E-VM; Mon, 09 Jan 2023 08:29:18 -0500 From: "Roger Sayle" To: "'GCC Patches'" Cc: "'Tom de Vries'" Subject: [nvptx PATCH] Correct pattern for popcountdi2 insn in nvptx.md. Date: Mon, 9 Jan 2023 13:29:14 -0000 Message-ID: <00b601d9242e$5fe32ec0$1fa98c40$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdkkLd2N28F2ka0RRhi9bl+W1tJODQ== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, MEDICAL_SUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP 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: , 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?1754551816972990521?= X-GMAIL-MSGID: =?utf-8?q?1754551816972990521?= The result of a POPCOUNT operation in RTL should have the same mode as its operand. This corrects the specification of popcount in the nvptx backend, splitting the current generic define_insn into two, one for popcountsi2 and the other for popcountdi2 (the latter with an explicit truncate). This patch has been tested on nvptx-none (hosted on x86_64-pc-linux-gnu) with make and make -k check with no new failures. This functionality is already tested by gcc.target/nvptx/popc-[123].c. Ok for mainline? 2023-01-09 Roger Sayle gcc/ChangeLog * config/nvptx/nvptx.md (popcount2): Split into... (popcountsi2): define_insn handling SImode popcount. (popcountdi2): define_insn handling DImode popcount, with an explicit truncate:SI to produce an SImode result. Thanks in advance, Roger diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index 740c4de..461540e 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -658,11 +658,18 @@ DONE; }) -(define_insn "popcount2" +(define_insn "popcountsi2" [(set (match_operand:SI 0 "nvptx_register_operand" "=R") - (popcount:SI (match_operand:SDIM 1 "nvptx_register_operand" "R")))] + (popcount:SI (match_operand:SI 1 "nvptx_register_operand" "R")))] "" - "%.\\tpopc.b%T1\\t%0, %1;") + "%.\\tpopc.b32\\t%0, %1;") + +(define_insn "popcountdi2" + [(set (match_operand:SI 0 "nvptx_register_operand" "=R") + (truncate:SI + (popcount:DI (match_operand:DI 1 "nvptx_register_operand" "R"))))] + "" + "%.\\tpopc.b64\\t%0, %1;") ;; Multiplication variants