From patchwork Sat Sep 11 09:28:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 1526702 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nextmovesoftware.com header.i=@nextmovesoftware.com header.a=rsa-sha256 header.s=default header.b=iyY77ODU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H66rJ0gGSz9sX3 for ; Sat, 11 Sep 2021 19:29:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F26F3857829 for ; Sat, 11 Sep 2021 09:28:59 +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 7A3F23858C27 for ; Sat, 11 Sep 2021 09:28:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A3F23858C27 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:To:From:Sender:Reply-To:Cc: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=6tfCaTi8uLYxqAZeI3Dbx4wdnRTMpMVjUuPscwug8HY=; b=iyY77ODUnp0I0GngmFB0qo5pY9 aeR67N9pK34q4T73DIQd3ikzKKyCPpfb97g6Vyy/wKcEdzJvMFq6LCTsKTG0Mmfyl7uYCCiM/AmHj dbi+Za+xZycHnkAHFyMaBebOz4pOMf/7KC2sjF7oZk31/8Tjsoac8GKEPcRwc0ifiWqb6uztiH1sL LqO1MGCKkdNYHTWQbSlLAWjmI9ofjYisYOTEqtZp/umi1xvl9U+ZlYlnO4ZTxh5iK8RyjONBqjaHg DeW4tGz7YIIul0Aj+YqdLWeaDWp4pnvK9Q9B5dTTBUUbAGO9j7CSQQB2xWDYrMGmKQQqb73knZUaa jZDu4yKg==; Received: from host86-168-251-41.range86-168.btcentralplus.com ([86.168.251.41]:60192 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mOzJW-0004VT-Kl for gcc-patches@gcc.gnu.org; Sat, 11 Sep 2021 05:28:46 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] Also preserve SUBREG_PROMOTED_VAR_P in expr.c's convert_move. Date: Sat, 11 Sep 2021 10:28:43 +0100 Message-ID: <00a901d7a6ef$6b352ac0$419f8040$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 thread-index: Adem7rLIlVz23rvWRC2TfmXGMEoM7A== 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=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch catches another place in the middle-end where it's possible to preserve the SUBREG_PROMOTED_VAR_P annotation on a subreg to the benefit of later RTL optimizations. This adds the same logic to expr.c's convert_move as recently added to convert_modes. On nvptx-none, the simple test program: short foo (char c) { return c; } currently generates three instructions: mov.u32 %r23, %ar0; cvt.u16.u32 %r24, %r23; cvt.s32.s16 %value, %r24; with this patch, we now generate just one: mov.u32 %value, %ar0; This patch should look familiar, it's almost identical to the recent patch https://gcc.gnu.org/pipermail/gcc-patches/2021-August/578331.html but with the fix https://gcc.gnu.org/pipermail/gcc-patches/2021-August/578519.html [Apologies again for this breakage on affected (non-x86_64) targets; I hope having that fixed within a few hours (before many folks even noticed a problem) minimized the inconvenience]. This patch has been tested on x86_64-pc-linux-gnu with "make bootstrap" and "make -k check" with no new failures, and on a cross-compiler to nvptx-none, with no new failures in its testsuite. OK for mainline? 2021-09-11 Roger Sayle gcc/ChangeLog * expr.c (convert_move): Preserve SUBREG_PROMOTED_VAR_P when creating a (wider) partial subreg from a SUBREG_PROMOTED_VAR_P subreg. Roger diff --git a/gcc/expr.c b/gcc/expr.c index 17f2c2f..e0bcbcc 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -236,8 +236,27 @@ convert_move (rtx to, rtx from, int unsignedp) >= GET_MODE_PRECISION (to_int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp)) { + scalar_int_mode int_orig_mode; + scalar_int_mode int_inner_mode; + machine_mode orig_mode = GET_MODE (from); + from = gen_lowpart (to_int_mode, SUBREG_REG (from)); from_mode = to_int_mode; + + /* Preserve SUBREG_PROMOTED_VAR_P if the new mode is wider than + the original mode, but narrower than the inner mode. */ + if (GET_CODE (from) == SUBREG + && is_a (orig_mode, &int_orig_mode) + && GET_MODE_PRECISION (to_int_mode) + > GET_MODE_PRECISION (int_orig_mode) + && is_a (GET_MODE (SUBREG_REG (from)), + &int_inner_mode) + && GET_MODE_PRECISION (int_inner_mode) + > GET_MODE_PRECISION (to_int_mode)) + { + SUBREG_PROMOTED_VAR_P (from) = 1; + SUBREG_PROMOTED_SET (from, unsignedp); + } } gcc_assert (GET_CODE (to) != SUBREG || !SUBREG_PROMOTED_VAR_P (to));