From patchwork Mon Nov 14 16:29:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawei X-Patchwork-Id: 19876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2237429wru; Mon, 14 Nov 2022 08:30:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf4HZBWWZN7YoKrbjUmiEKoOoRYRdiI6053l2eO+FmihW3wNsKM15YXM2a/Hu2g2BS/DfJCB X-Received: by 2002:a05:6402:519:b0:467:6847:1ea7 with SMTP id m25-20020a056402051900b0046768471ea7mr10825692edv.237.1668443407951; Mon, 14 Nov 2022 08:30:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443407; cv=none; d=google.com; s=arc-20160816; b=b/w11kaaDkZK2SC4M8fX8OBag/erVzzJFu7Eod52vAW6Nqr7puLUj5ZPj1kFbnBzzi dQz77eLPy6z7bMCljrG/kAIgFmNIbDLbUHMOo7cxQI8i0aHyo66NhZNKmpPbLXA2Envb R/M3njoXNfTZp9PlEi8bzFejdoefB9EaqraQ9qw1Ak9QZL5+OoGGrMxzOQ+T/FMtEeW9 QezmhbX2SAiG3yKgFhFpWaYd2X4PqIDeXvlUkENDHmubVNZu8g7R2LB0UaUTGPZa+Dnf fobMzJuppItoI4KYtIjZaN2QIZgPtGiF/w63uu8UnQBtJKk9jhTWXJvffA3FJUjm/v1g syig== 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-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dmarc-filter :delivered-to; bh=NW1ZzcmzDV345UOhcyHeib9dxXDFnyH5LAuCMvz8MuM=; b=C0Xnn+hIEuNmblPAfyBz/io1/So3fLx3ZBEi7CIDjh9X7GyItUrs8TVEjLsjcZYxP4 tvw3LQULou6+LfsEORFhzSgnmdFJV28M1JwZDWEg6QubwvXOqwNeX4i9gVVYPqwqGXGq Nn6oCFNdQo10/LQBPzACsI6eVYLpV5zJFAJOUUN5ythEs9lbwgKowo4NU1VHcyaCOD5M wz5DtnFyRQclZw6Grojp+WYu+cKFwueMXxRiGkp/hQZc4PimbGs0dbIhwwS5LOfsvMIo WF1AW9EqsHLCrTXptTZJU7maySGHII1nCGl2OfXteuNDuPL4RRbutCO3mdHwokgCxz8A 0+/A== ARC-Authentication-Results: i=1; mx.google.com; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l8-20020aa7cac8000000b00461d02225a3si8308734edt.448.2022.11.14.08.30.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 08:30:07 -0800 (PST) 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; 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 B4CD43858C1F for ; Mon, 14 Nov 2022 16:30:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by sourceware.org (Postfix) with ESMTP id B80903858D1E for ; Mon, 14 Nov 2022 16:29:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B80903858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost.localdomain (unknown [47.113.87.88]) by APP-01 (Coremail) with SMTP id qwCowABX92jsbHJjFqrGCQ--.62802S2; Tue, 15 Nov 2022 00:29:32 +0800 (CST) From: jiawei To: gcc-patches@gcc.gnu.org Cc: kito.cheng@sifive.com, palmer@rivosinc.com, juzhe.zhong@rivai.ai, christoph.muellner@vrull.eu, philipp.tomsich@vrull.eu, wuwei2016@iscas.ac.cn, jiawei Subject: [PATCH] RISC-V: Optimal RVV epilogue logic. Date: Tue, 15 Nov 2022 00:29:18 +0800 Message-Id: <20221114162918.1563116-1-jiawei@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: qwCowABX92jsbHJjFqrGCQ--.62802S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr1UCF1kCry7Gr45tr1rtFb_yoW8XFyrpF s8Wr1IvF1Yvwn3t3WxtFWakr1UWw4fKw45C34UAr43Aw4DWrW8Wrsxtay3Wr4qgFWkAr97 uF1qkrn0va1xA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkY14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r1j 6r4UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r1j6r 4UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFjwCF04k2 0xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI 8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41l IxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIx AIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUU7GYJUUUUU== X-Originating-IP: [47.113.87.88] X-CM-SenderInfo: 5mld4v3l6l2u1dvotugofq/1tbiCgMKAGNyU1g62QAAs6 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, 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?1749489715137592286?= X-GMAIL-MSGID: =?utf-8?q?1749489715137592286?= Skip add insn generate if the adjust size equal to zero. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_epilogue): New if control segement. --- gcc/config/riscv/riscv.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 02a01ca0b7c..af138db7545 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -5186,24 +5186,26 @@ riscv_expand_epilogue (int style) } /* Get an rtx for STEP1 that we can add to BASE. */ - rtx adjust = GEN_INT (step1.to_constant ()); - if (!SMALL_OPERAND (step1.to_constant ())) + if (step1.to_constant () != 0){ + rtx adjust = GEN_INT (step1.to_constant ()); + if (!SMALL_OPERAND (step1.to_constant ())) { riscv_emit_move (RISCV_PROLOGUE_TEMP (Pmode), adjust); adjust = RISCV_PROLOGUE_TEMP (Pmode); } - insn = emit_insn ( + insn = emit_insn ( gen_add3_insn (stack_pointer_rtx, stack_pointer_rtx, adjust)); - rtx dwarf = NULL_RTX; - rtx cfa_adjust_rtx = gen_rtx_PLUS (Pmode, stack_pointer_rtx, + rtx dwarf = NULL_RTX; + rtx cfa_adjust_rtx = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (step2)); - dwarf = alloc_reg_note (REG_CFA_DEF_CFA, cfa_adjust_rtx, dwarf); - RTX_FRAME_RELATED_P (insn) = 1; + dwarf = alloc_reg_note (REG_CFA_DEF_CFA, cfa_adjust_rtx, dwarf); + RTX_FRAME_RELATED_P (insn) = 1; - REG_NOTES (insn) = dwarf; + REG_NOTES (insn) = dwarf; + } } else if (frame_pointer_needed) {