From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id F26643858D3C for ; Tue, 25 Jul 2023 11:19:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F26643858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2b933bbd3eeso78804231fa.1 for ; Tue, 25 Jul 2023 04:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690283961; x=1690888761; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9zExxlDIxAgBhV56VbG9+feYnH+bIR4uuSyf7UAgFNw=; b=Qt+jwG866O27HOtzrwffeynKHt3Kj5q83bfSbnxLdKOPz1eWPTht7ZEsO6jcuv5HQw eSaFVYjih2W61Jrh3btSMfILT/rGUmPuKj9FBFZjchorDRoV29zb5259XUHKIYRMYES/ U8hV9LOnl36WvOf7cCLatSua0cSQIb+cP9+owH54pbt5bejC+KFBZZDE09WxgyVqf0xF 4XWiFzedBrVTgzFiGxXwNulhDYkzuXd4yuBW6CGDFkzZmUoCPk8AAvqt/r5ZLW0eqKDZ YwCOg8hX3IY5BoOhkDgey3LOe8uugHw6dGneGTxLP5PzT/Gd8Rdp3F1JGlauwN6ORiVl pXzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690283961; x=1690888761; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9zExxlDIxAgBhV56VbG9+feYnH+bIR4uuSyf7UAgFNw=; b=dCQ/qwlhJcC3V6ZMadbmnHqxuwzvPMxx6SUfEQulDRKsyk6A1SqhIC27e/rl0nZltv MBEbLlW0T1FTwZLqQpIp/9bNfbrkX7jRp1mau6tTrrT8jfjE89T2jcwu8y3FNx4o01VO Zcrhg5Ey1ofhyzSjtEzjBbhnNtmK898t49uskLokx+PAXEr+lDjPuaR81hGbDpzH1Ko8 b7cySupvJThuhrOwkWNXorc7HsjPMYYuLzXn/RFOCMK8coDCGeniU8T99diBGwv1KcGp yIG1dlj29sNffLVlav7Ltl6RNosfi29xeaPOQVg/OubUuR88ILyDlp7TEbIK7L0v3ghr Vykg== X-Gm-Message-State: ABy/qLY782y7Df4QhdLiXptyv30KdFNGz1bBIkDzdtDHcxl1wLeNWpKN hnygCAjcYN2sABsEpX5cjeNic7uVOVUlTRAnda6XIbjhZOo= X-Google-Smtp-Source: APBJJlELyR5QhAGxZqmsi5r5s3Dbkjuj6S8PAAX6RQrFYMAizNuGF+zpYLyqpvfjJcEq8w+6Q0WqUDXN2Lfn25/DdDU= X-Received: by 2002:a2e:9f50:0:b0:2b7:33a6:f2c0 with SMTP id v16-20020a2e9f50000000b002b733a6f2c0mr8793106ljk.4.1690283960909; Tue, 25 Jul 2023 04:19:20 -0700 (PDT) MIME-Version: 1.0 References: <00ef01d9bcbb$d50aeeb0$7f20cc10$@nextmovesoftware.com> In-Reply-To: <00ef01d9bcbb$d50aeeb0$7f20cc10$@nextmovesoftware.com> From: Richard Biener Date: Tue, 25 Jul 2023 13:18:38 +0200 Message-ID: Subject: Re: [PATCH] Replace lra-spill.cc's return_regno_p with return_reg_p. To: Roger Sayle Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 List-Id: On Sat, Jul 22, 2023 at 6:45=E2=80=AFPM Roger Sayle wrote: > > > This patch is my attempt to address the compile-time hog issue > in PR rtl-optimization/110587. Richard Biener's analysis shows that > compilation of pr28071.c with -O0 currently spends ~70% in timer > "LRA non-specific" due to return_regno_p failing to filter a large > number of calls to regno_in_use_p, resulting in quadratic behaviour. > > For this pathological test case, things can be improved significantly. > Although the return register (%rax) is indeed mentioned a large > number of times in this function, due to inlining, the inlined functions > access the returned register in TImode, whereas the current function > returns a DImode. Hence the check to see if we're the last SET of the > return register, which should be followed by a USE, can be improved > by also testing the mode. Implementation-wise, rather than pass an > additional mode parameter to LRA's local return_regno_p function, which > only has a single caller, it's more convenient to pass the rtx REG_P, > and from this extract both the REGNO and the mode in the callee, and > rename this function to return_reg_p. > > The good news is that with this change "LRA non-specific" drops from > 70% to 13%. > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, with no new failures. Ok for mainline? I think this is a good heuristic improvement, but I don't feel competent on assessing the constraints this implies on the structure of the return value setting instructions. Previously we'd preserve noop copies mentioning the return hardreg but now just if that noop copy has the same mode as the return_rtx. I don't even understand why we need to preserve this noop copy in the first place. Looking at the history of return_regno_p and the surrounding of the single caller tells this is a place of "interestingness" ... Can somebody summarize why we need to preserve a noop-move between the return_rtx (hard?)regs? The comment /* IRA can generate move insns involving pseudos. It is better remove them earlier to speed up compiler a bit. It is also better to do it here as they might not pass final RTL check in LRA, (e.g. insn moving a control register into itself). So remove an useless move insn unless next insn is USE marking the return reg (we should save this as some subsequent optimizations assume that such original insns are saved). */ says this is about removing noop copies of _pseudos_ for correctness reasons. So, can't we simply scrap the return_regno_p and regno_in_use_p checks and always preserve noop moves between hardregs here, leaving that to other passes? I'm going to bootstrap & test that for the fun of it. Thanks, Richard. > > > 2023-07-22 Roger Sayle > > gcc/ChangeLog > PR middle-end/28071 > PR rtl-optimization/110587 > * lra-spills.cc (return_regno_p): Change argument and rename to..= . > (return_reg_p): Check if the given register RTX has the same > REGNO and machine mode as the function's return value. > (lra_final_code_change): Update call to return_reg_p. > > > Thanks in advance, > Roger > -- >