From patchwork Sat Mar 4 18:32:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 66011 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 A3B6B385B52E for ; Sat, 4 Mar 2023 18:32:36 +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 2A2893858D28 for ; Sat, 4 Mar 2023 18:32:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A2893858D28 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=3wOSjgvQYuqniGDsUPSYCk5xQmueoeNthA6cKA8q2dc=; b=RMsoneYnzlERFXY1/prnFZttgB ZJ4ms5l4DF+m+M7pM4LbTgI9u03H8jFS9H59P1S28bASS9dEn0oB8dUJ4u9GftzTQlhIvFE2AJ+OV CcYBSP9ICCMTm2Mvy3dSUmpsU8PSkzP3iKemshswcv03kpvgfVO6saNHPvV9GBqpOzJyP/r6H+db9 vLD1PW7VCb/VXE5MtVEdqZL0f94Kfr8ZggdwhjqXlOFnAhf32SKO/c5WREsCCzm3XB7XXFfo1vEUw 7ReTdcs6+Lc5njHRGB27myN5DDXlIAbcOTsf/gKznGcyn8bgB+FJwk9mP1Y3UNss1FLQZ06PUsz4j 7a/mOSIQ==; Received: from host86-163-35-31.range86-163.btcentralplus.com ([86.163.35.31]:63004 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 1pYWg6-0002M6-Tl; Sat, 04 Mar 2023 13:32:19 -0500 From: "Roger Sayle" To: "'GCC Patches'" Cc: "'Tamar Christina'" , "'Richard Sandiford'" , "'Segher Boessenkool'" Subject: [PATCH] PR rtl-optimization/106594: Preserve zero_extend in combine when cheap. Date: Sat, 4 Mar 2023 18:32:15 -0000 Message-ID: <000c01d94ec7$a6921430$f3b63c90$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdlOxlGLdZf5RsEKSy2T3BJGVUY5jA== 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=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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" This patch addresses PR rtl-optimization/106594, a P1 performance regression affecting aarch64. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32}, with no new failures. If someone (who can regression test this on aarch64) could take this from here that would be much appreciated. Thanks in advance. 2023-03-04 Roger Sayle gcc/ChangeLog PR rtl-optimization/106594 * combine.cc (expand_compound_operation): Don't expand/transform ZERO_EXTEND or SIGN_EXTEND on targets where rtx_cost claims they are cheap. Roger diff --git a/gcc/combine.cc b/gcc/combine.cc index 0538795..cf126c8 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -7288,7 +7288,17 @@ expand_compound_operation (rtx x) && (STORE_FLAG_VALUE & ~GET_MODE_MASK (inner_mode)) == 0) return SUBREG_REG (XEXP (x, 0)); + /* If ZERO_EXTEND is cheap on this target, do nothing, + i.e. don't attempt to convert it to a pair of shifts. */ + if (set_src_cost (x, mode, optimize_this_for_speed_p) + <= COSTS_N_INSNS (1)) + return x; } + /* Likewise, if SIGN_EXTEND is cheap, do nothing. */ + else if (GET_CODE (x) == SIGN_EXTEND + && set_src_cost (x, mode, optimize_this_for_speed_p) + <= COSTS_N_INSNS (1)) + return x; /* If we reach here, we want to return a pair of shifts. The inner shift is a left shift of BITSIZE - POS - LEN bits. The outer