From patchwork Tue Jul 25 11:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 125530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2402675vqg; Tue, 25 Jul 2023 04:32:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGMDFw8A5ItjIoTyHvUcNvcApOZbhQybGPEBBts9EXKF+PZcC2WYsEzTbDlu/P5zWhR7wK5 X-Received: by 2002:a17:906:6492:b0:994:62ee:7531 with SMTP id e18-20020a170906649200b0099462ee7531mr12551061ejm.58.1690284779361; Tue, 25 Jul 2023 04:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690284779; cv=none; d=google.com; s=arc-20160816; b=qoKKImuVA7+YNdPs7VLYddV9MoEIuoPuhnmdkM/LndAS6vnmLz1XUBVebTvHcrhn8h J04/t2UDCcZ/M2q9QzyVUH8sJDDUknMZCE35PBHq10uwYpcMq236UOw0+xQtGmOTmQBK misaaJ11e+nkDCf/+EhRjIgjiFCxSjvcqFQzsQX0rk8GeZJCNYIjjzuzeGCAhwuXaDV/ 2nqpYdMSfO77W/b5nXbN+b5s+zax0JSnjpGO9AwcpIzutGzSSJlSOxPmTbA7AzPdVKBg dIXk88aZrjCDaBfI6JoqKj1gPwTlfhWw0a2RaZ7soXZIvty/u2wlCO8lKQyPCmjrOGKC ZjXg== 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=2+tLY0Vwvu01DULI+PgLMX4HYyB8GFFNR5jJSTxNQgo=; fh=u1SoRjjns8FN8m8jx748MPuRQEC5av1V2pL5yQLhm3I=; b=WcFs53j98HN4f5om96tiyZ0tJFLvrDBfpEKS3ZcBO5Ic4IFJAl0QVZA+6fNedAKD95 lfCiX7OMZWhjHP4IcDtOEZXvFWW2r9vg+e4mkjmVqQMBowZdnCTdVna3DcqJxl7srhHa E9k+421cLVICp+1CZR7R6qd9g8noA6+WKWsPIDQ1IlLvlsNiktmmhtlwPVrUNGvsyxEa fzMyhfRHSHSg4p7QxFuvIDG3JfMtYO2xJ8ktVITEhIeJuCIJJcxVRtjcElrnagUFwgtr tPDJtrE3w2hT4qloHOUVY52QKRVv2xi8bqjaR+J5bpXRkuWysIkPFaNxy12IqAWNaHBG LA2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=C9CWe38A; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m3-20020a170906720300b00987a0569370si7370894ejk.703.2023.07.25.04.32.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 04:32:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=C9CWe38A; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 86ED4385C6E3 for ; Tue, 25 Jul 2023 11:32:39 +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 66CE93857036 for ; Tue, 25 Jul 2023 11:31:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66CE93857036 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=2+tLY0Vwvu01DULI+PgLMX4HYyB8GFFNR5jJSTxNQgo=; b=C9CWe38AMw49K44VFk6njcenKW AniiNgxOeTM5HpObAxd0eTwTdcLLmNi7hJ2ywOu0yFmdGDAvX57Ms/ymx7fNGpVOkEiVBieHmOkQF 1oliwrEREC8z5ghfCsN+Fh2I4D8zqR4LuNxm3EIgFFXFLGB7Bv6kk/gulZZWdKuL0jeaXNHEgL92Z q+1OVQk7eJNaNN/ReGoxwHxoqrQ5DdRwHqumBYBH3qul+fKyTaKvPHLecqOWIH0wSgiTjKOASfoLk oaWTOdXMHQftqa2lMornBGazSbfIdyyrSKa7qrY21t5hWuMze1L9dAziQM/8mFPWjZIZgN2ZNqrX+ OajHBUKQ==; Received: from [185.62.158.67] (port=57573 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qOGGZ-0007ac-1I; Tue, 25 Jul 2023 07:31:47 -0400 From: "Roger Sayle" To: Cc: "'Richard Biener'" Subject: [PATCH] PR rtl-optimization/110587: Reduce useless moves in compile-time hog. Date: Tue, 25 Jul 2023 12:31:45 +0100 Message-ID: <004c01d9beeb$98c6fcf0$ca54f6d0$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adm+6zbWFvtJ7g2wSOqTed74IJ6CIg== 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.4 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, T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1772392052623704581 X-GMAIL-MSGID: 1772392052623704581 This patch is the third in series of fixes for PR rtl-optimization/110587, a compile-time regression with -O0, that attempts to address the underlying cause. As noted previously, the pathological test case pr28071.c contains a large number of useless register-to-register moves that can produce quadratic behaviour (in LRA). These move are generated during RTL expansion in emit_group_load_1, where the middle-end attempts to simplify the source before calling extract_bit_field. This is reasonable if the source is a complex expression (from before the tree-ssa optimizers), or a SUBREG, or a hard register, but it's not particularly useful to copy a pseudo register into a new pseudo register. This patch eliminates that redundancy. The -fdump-tree-expand for pr28071.c compiled with -O0 currently contains 777K lines, with this patch it contains 717K lines, i.e. saving about 60K lines (admittedly of debugging text output, but it makes the point). 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. Ok for mainline? As always, I'm happy to revert this change quickly if there's a problem, and investigate why this additional copy might (still) be needed on other non-x86 targets. 2023-07-25 Roger Sayle gcc/ChangeLog PR middle-end/28071 PR rtl-optimization/110587 * expr.cc (emit_group_load_1): Avoid copying a pseudo register into a new pseudo register, i.e. only copy hard regs into a new pseudo. Thanks in advance, Roger diff --git a/gcc/expr.cc b/gcc/expr.cc index fff09dc..11d041b 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -2622,6 +2622,7 @@ emit_group_load_1 (rtx *tmps, rtx dst, rtx orig_src, tree type, be loaded directly into the destination. */ src = orig_src; if (!MEM_P (orig_src) + && (!REG_P (orig_src) || HARD_REGISTER_P (orig_src)) && (!CONSTANT_P (orig_src) || (GET_MODE (orig_src) != mode && GET_MODE (orig_src) != VOIDmode)))