From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 9C6313858C50 for ; Mon, 17 Apr 2023 22:51:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C6313858C50 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-pl1-x635.google.com with SMTP id la15so4407441plb.11 for ; Mon, 17 Apr 2023 15:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681771894; x=1684363894; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=GV4WP1wGaXcJrJgei003i7rqqM2u2+hXyCiqXrus3sk=; b=cOt1d+74YMZvPFGamxf98sz1ZOMnRwwf6Bjq+8XilE3dBuxClb2zCmK1XxYXrBxFk4 JSqP0car5nZsfbLiZpGTHdUHVMCiw8aVgVe9FwBF9CB7kTOaFAcveZw9Zi3ihc0oKwDe m2J6roxC+bQQ9m/3GKRE9HcnFjKxUHdUDBZMCdWDA8S57EBnHCYk4jT2k+cBfCBdQxBN FnAV8g8KnEJJRL+puTWEhEJr3qnpshzlhFUf8VGsoFunYTVqx/Gzo2oeJ1sgFxhQOEC7 OUKojmzgUyb/W8DeuEgiAjiQeLFvEsn1vXiXeZW9nXudBByDkHSU5dXEWgurap1bvFkF TLNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681771894; x=1684363894; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GV4WP1wGaXcJrJgei003i7rqqM2u2+hXyCiqXrus3sk=; b=jsODt1pLOU35+6WUAA7mUgNpIkphsgv/zKh++wjYUu2vmDBnhHof+mO24JbOSJ1gqc R5VcbcTZI1wqDtVR3fanT1UddUhLj/9AfBPPWnW6hzQsvfpGa2k8d8L2O2md1gye3L/O FxjqBvxTHEqR4xUtvoewYeS7vpgli796JNaq9flh8j8gGO1BIPhs4R01Ocau4hMBQQDK qrpvbzkDJjSPGj+iGwrxy0pqUBvCwy3wZmAOwUqz3seVOKBPeF95AlKRmhE9ScP7bh8R 6q5snFu+H0XjmYwjB0uZkZLIrIDC7GM6MYifDysFBiGkkU/mTk3wOvn7OemM9DR6hCp7 R9yg== X-Gm-Message-State: AAQBX9eqLtnJdFlWrzQWYJ97bg3FM8wwNHyiAHYbjeJY94XnO1dQ2inh yXnCLyyy0sB+rmaMgTVVg5Q= X-Google-Smtp-Source: AKy350Z1UhBBn5sHdjdDphGtkV0DDYXDxwvZKVYaR9rDmkS/US7/YzRHRfe5gM54pOSJfmb98QGaeA== X-Received: by 2002:a05:6a20:4f25:b0:d8:161e:46 with SMTP id gi37-20020a056a204f2500b000d8161e0046mr16273441pzb.58.1681771894119; Mon, 17 Apr 2023 15:51:34 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id z22-20020aa791d6000000b0063b87f47062sm2078260pfa.127.2023.04.17.15.51.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Apr 2023 15:51:33 -0700 (PDT) Message-ID: Date: Mon, 17 Apr 2023 16:51:32 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH 2/3] RISC-V: optimize stack manipulation in save-restore Content-Language: en-US To: Fei Gao , gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com References: <20221201100332.22226-1-gaofei@eswincomputing.com> <20221201100332.22226-3-gaofei@eswincomputing.com> From: Jeff Law In-Reply-To: <20221201100332.22226-3-gaofei@eswincomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,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 12/1/22 03:03, Fei Gao wrote: > The stack that save-restore reserves is not well accumulated in stack allocation and deallocation. > This patch allows less instructions to be used in stack allocation and deallocation if save-restore enabled. > > before patch: > bar: > call t0,__riscv_save_4 > addi sp,sp,-64 > ... > li t0,-12288 > addi t0,t0,-1968 # optimized out after patch > add sp,sp,t0 # prologue > ... > li t0,12288 # epilogue > addi t0,t0,2000 # optimized out after patch > add sp,sp,t0 > ... > addi sp,sp,32 > tail __riscv_restore_4 > > after patch: > bar: > call t0,__riscv_save_4 > addi sp,sp,-2032 > ... > li t0,-12288 > add sp,sp,t0 # prologue > ... > li t0,12288 # epilogue > add sp,sp,t0 > ... > addi sp,sp,2032 > tail __riscv_restore_4 > > gcc/ChangeLog: > > * config/riscv/riscv.cc (riscv_expand_prologue): consider save-restore in stack allocation. > (riscv_expand_epilogue): consider save-restore in stack deallocation. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/stack_save_restore.c: New test. I made a couple of whitespace fixes and pushed this to the trunk after running it through a cross testing cycle. Thanks! jeff