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: 64262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1041883wrd; Sat, 4 Mar 2023 10:32:49 -0800 (PST) X-Google-Smtp-Source: AK7set8jmj2aTRzAU7eR/jdRtAAX8djmOZs3If1PMhs4b0DXH3cY1pwZitO6hWTQUreCgtIjSXn4 X-Received: by 2002:a17:907:16a4:b0:8af:3fcc:2b05 with SMTP id hc36-20020a17090716a400b008af3fcc2b05mr7224973ejc.12.1677954769571; Sat, 04 Mar 2023 10:32:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677954769; cv=none; d=google.com; s=arc-20160816; b=TsSdDj/ztFcUCNlXdISPy7psnTs/UBz4skC5sznBLbVCRe9xGkuwfeRRlQeTUQWDyh 9vkSZ5NK3MB+rouTpWJZNC8eB7JFe9imSFEf/LZ8/ZP874bFe974f3y4BKDdeLu6Scpk j6YWGSMIQb+vqs4qyHnIJydKfZPt7wB9J000VzeUDUXOPRSm44rY+DuQWX7Tj9ihQ+vZ y5nS4oZgZTWz+vGhme9mnfQ2ZaRV1JlkYxHy8Dpfg0Zx5OG+N9oNaHbYwBTQV5FxOrv6 DqxJ5r+DPa/eleyNZvXCk1KVMO4hGjiKY8oEPrT2hubKgx8jB3C9wE68xdDX+UY5JqTx P+8w== 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=3wOSjgvQYuqniGDsUPSYCk5xQmueoeNthA6cKA8q2dc=; b=VmJfU5IH3Cq1CGIr5yUdJgAU924LUCA3U8R9CNViQqzsCXaWR2Ak+U24OdJgiXzNo6 o36c91PL1y14d6N6SEkkmPlNeU2C0CRmE/Rj7hexxln3KYhiqQyZutcuVBu25L5yX/kE B8Xq3TND41bZXG5KaMoolhLGBwVmx50dkRo3zetZ9rMyKy3t5K5wvEEJih50AZpOZACL wozOX2bAmOh4LL+iCTi4RQlw8BD3rFBE08rtyyycT43dPcRxUHij3pM/OJAKTOCBD4BI RyINeaiPO6ZbR9vaa1N2P83Ww7L5/aYADDZIP/ynhJ+rCLENiOAEyv1h43kTg5fFoigv eYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=RMsoneYn; 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 um16-20020a170906cf9000b008c72577b130si5369619ejb.636.2023.03.04.10.32.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Mar 2023 10:32:49 -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=RMsoneYn; 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 9F4DE385B511 for ; Sat, 4 Mar 2023 18:32:44 +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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759463100518016454?= X-GMAIL-MSGID: =?utf-8?q?1759463100518016454?= 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