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: 62847 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5AC1A3857BA4 for ; Mon, 9 Jan 2023 13:29:34 +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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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