From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by sourceware.org (Postfix) with ESMTPS id 1C9E23857370 for ; Fri, 9 Sep 2022 22:22:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C9E23857370 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-yb1-xb2b.google.com with SMTP id k80so4644063ybk.10 for ; Fri, 09 Sep 2022 15:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=lozTSgKOaiyupLzWVUSupEC/TAvsLo9PXh3Mb80+sCw=; b=l94cNMb+GjUNHpwkvK4nwcf/Eqine1gQYOmxygJD8PCy5+6jUe3ioma9fAQX5gBnio uRun4bEntzJnUxhi9pADDXv6mzKkv95T23b8tsQGdXy6kxmgozdoLgmajISmaGLP1+v5 Vht9/FDZO31ACwTY2E3pFPu8WBt6yjLcqXQ/uHhL1u9IuPkXZw2qaVEwDKn1lZtlNXwI Ypv25KG1+Nj+t3g+oOlNv6QdKlv5KiVrxuRASLxnh+Pzlx/ReMwcnhyVgEMO3rQahW5b dAOWm44uhAfl7msFo1kXIGIMIbVL4O6Sps+szzl3nQ+bjlE2i6mBnwMuyt99abWeiDAK UXNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=lozTSgKOaiyupLzWVUSupEC/TAvsLo9PXh3Mb80+sCw=; b=bGCFP7Hv7DskexcGDoVcS17H9qJLwkBYdIrUFT6DDFc+awi7LNrdG1jSncs46iMuBA 2rv0OHpntOIz1tGt4rJ1j10c70P6/jzr4sDP1lMklv25XhL5Iv/j3N3VkOD9+1dhZ/08 bTDfA0pgIYtGstM76sUnW7oRUeGwvTPOzs1txS5hFwAzQk+8GwDVJUIjVbOGQ5O9rsgC 9Ppr1WB7SdmFGbnZsSqrmI8zSKV1/Zja/aNDoL6wrgmpQw7gfBqCLD3H9iHYPXyHwpqZ lAYMMlINmnNcUrcv1Ndp02GhK9ayVdxmUxY9mmAU4jLDCvtGTcaYkxZF6QgjU//TEZ9h t+bA== X-Gm-Message-State: ACgBeo20MkqAEmmTZusjFVVDmQowFeKvZVXxwH+IOY77qBDacuLBlW4A fzjiI956GOMy9ViJzCmR1LC109079VGMWUzk8kA= X-Google-Smtp-Source: AA6agR4t0u7dTP2VPmZGxf9WuIjhDrRLVtPENLRRn5mVoAQghSTC2Y/vvD3vQ791OVF+/wUGKhWS1wqIRWQ1N6cts4g= X-Received: by 2002:a5b:ac9:0:b0:67b:4ba1:cde7 with SMTP id a9-20020a5b0ac9000000b0067b4ba1cde7mr14010540ybr.70.1662762166480; Fri, 09 Sep 2022 15:22:46 -0700 (PDT) MIME-Version: 1.0 References: <58b7fe91-a678-0cfd-9697-aa565bda0d68@yahoo.co.jp> In-Reply-To: <58b7fe91-a678-0cfd-9697-aa565bda0d68@yahoo.co.jp> From: Max Filippov Date: Fri, 9 Sep 2022 15:22:35 -0700 Message-ID: Subject: Re: [PATCH v4 1/2] xtensa: Eliminate unused stack frame allocation/freeing To: "Takayuki 'January June' Suwa" Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Sep 8, 2022 at 2:38 PM Takayuki 'January June' Suwa wrote: > > Changes from v3: > (xtensa_expand_prologue): Changed to exclude debug insns from DF use chain analysis. > > --- > > In the example below, 'x' is once placed on the stack frame and then read > into registers as the argument value of bar(): > > /* example */ > struct foo { > int a, b; > }; > extern struct foo bar(struct foo); > struct foo test(void) { > struct foo x = { 0, 1 }; > return bar(x); > } > > Thanks to the dead store elimination, the initialization of 'x' turns into > merely loading the immediates to registers, but corresponding stack frame > growth is not rolled back. As a result: > > ;; prereq: the CALL0 ABI > ;; before > test: > addi sp, sp, -16 // unused stack frame allocation/freeing > movi.n a2, 0 > movi.n a3, 1 > addi sp, sp, 16 // because no instructions that refer to > j.l bar, a9 // the stack pointer between the two > > This patch eliminates such unused stack frame allocation/freeing: > > ;; after > test: > movi.n a2, 0 > movi.n a3, 1 > j.l bar, a9 > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc (machine_function): New boolean member as > a flag that controls whether to emit the insns for stack pointer > adjustment inside of the pro/epilogue. > (xtensa_emit_adjust_stack_ptr): New function to share the common > codes and to emit insns if not inhibited. > (xtensa_expand_epilogue): Change to use the function mentioned > above when using the CALL0 ABI. > (xtensa_expand_prologue): Ditto. > And also change to set the inhibit flag used by > xtensa_emit_adjust_stack_ptr() to true if the stack pointer is only > used for its own adjustment. > --- > gcc/config/xtensa/xtensa.cc | 164 ++++++++++++++++++------------------ > 1 file changed, 80 insertions(+), 84 deletions(-) Regtested for target=xtensa-linux-uclibc, no new regressions. Committed to master. -- Thanks. -- Max