From patchwork Tue Apr 18 02:03:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 84542 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2527988vqo; Mon, 17 Apr 2023 19:05:02 -0700 (PDT) X-Google-Smtp-Source: AKy350YvU1LgsI1kM0K8grgLW0QZHmDunHjaC2NExntnFa9zWLBUx6ySaeFz46jlqB/LiQHG7DHw X-Received: by 2002:a17:907:8a1e:b0:94f:694e:b953 with SMTP id sc30-20020a1709078a1e00b0094f694eb953mr6623452ejc.59.1681783502715; Mon, 17 Apr 2023 19:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681783502; cv=none; d=google.com; s=arc-20160816; b=ndsxSGkBfUWEL7IK7++X8zxeF5jvwpv7pgHgFRNW+VeUXDcvtqqUPBum61w4y/HvHp Fezs6uROIBLAv16kCWNoghlqhUmRzNS+D2Jbm22u7lo29pOs/nJc/5ymEp3BGQ5ujsCX vYKgnC2kKIkj9fVykTEtZriM5RGsrw5f1OL/rTdewZpODKTDu2gPTn5DCyuFKGoY70gJ dwCn1FZTVK0zERtFSdoPFD8JOioxRJrilsE9qbBONTysudqsvts7Q0AUlGQoD31Zhvt2 99Rh7pQeA3x23ppcrvdRM10ZEgTYQmo9rrIe0IYWFfH2RmvuM4z2fm2BwM1rBAATaJk9 NGog== 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:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=ZQFBGY8m9WZ3040fx1/SKM0DFfkISrBqnHLa17gZdJk=; b=V4Xyuu6H+3WMB9LYz9Ut1WAskJS4OFZwfCGBVEgg8eBWNAtCXkPNUlz/x0StkPhRRw +cXlHT8jxHsayJhx819oT/CUuR155LTw00teub1q/JmLX030JLMxVoVAhRzgByeFwIcJ Lafo6x7dUY1ZPx+ra9m4mdhxMHtaJCMi/9QNEYaY1QHyOfc/mO3TsNXuXhYiTFYO95dc Bkd3xwQmNvLa8mptBPyfHXsDsKY0LgrexI8rLPVbVvy16fezX0W9i8//Il7hy0GhkVDc eqSxDu7tvVBrh2WdKvFwR4BK6D1zSYVQfh+noctcvjIYRvdh8J7ERrYRn231Njz6OevB DMwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fl13-20020a1709072a8d00b0094ef020584asi8123890ejc.32.2023.04.17.19.05.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 19:05:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 D16023858C39 for ; Tue, 18 Apr 2023 02:04:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by sourceware.org (Postfix) with ESMTPS id 67A5C3858D28 for ; Tue, 18 Apr 2023 02:04:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 67A5C3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp88t1681783394tr20doj9 Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 18 Apr 2023 10:03:12 +0800 (CST) X-QQ-SSF: 01400000000000F0P000000A0000000 X-QQ-FEAT: szTy5SWxjRlf53mTlHXprlE1XlsJ6rj+9189Zpz3LlLlkHAOj3tRCjUxlBLLq ykYRvjjCrEFj0Qu4ym9nbdfLvjHDW6yGMTfifjhwfeBlGvw3nQrucsXWxeAoJsZZYBuwkcY Rk2FCAynNtHkF+hz+KYeCVbR4TCpla/TUc2cM1TS852l6hTYBw6PKrw2kQ1XOnQLRokGwly UMOHKgQM3CU9RNv/Nzbm56lQhhic3Zkvjaxd3rP5qteUNDlx952xtcE/ljH/H6BajhQvlEm DGHt4aPHVIMKLTkfHURMrHMX5wUNGIFBBvHFKs0yzywAkwB5P+C6vyLC8SDmqugfVRmC71b lXdcOb81gAscilUfsQRQ0U/b3ieZnSc67Vc50qCK/1Oe8Fol7k= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 10440558313435390688 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, Ju-Zhe Zhong Subject: [PATCH] RISC-V: Fix PR109535 Date: Tue, 18 Apr 2023 10:03:11 +0800 Message-Id: <20230418020311.36368-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, T_SPF_HELO_TEMPERROR 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?1763477818230615749?= X-GMAIL-MSGID: =?utf-8?q?1763477818230615749?= From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (count_regno_occurrences): New function. (pass_vsetvl::cleanup_insns): Fix bug. --- gcc/config/riscv/riscv-vsetvl.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 1b66e3b9eeb..43e2cf08377 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -1592,6 +1592,19 @@ backward_propagate_worthwhile_p (const basic_block cfg_bb, return true; } +/* Count the number of REGNO in RINSN. */ +int +count_regno_occurrences (rtx_insn *rinsn, unsigned int regno) +{ + int count = 0; + extract_insn (rinsn); + for (int i = 0; i < recog_data.n_operands; i++) + if (REG_P (recog_data.operand[i]) + && REGNO (recog_data.operand[i]) == regno) + count++; + return count; +} + avl_info::avl_info (const avl_info &other) { m_value = other.get_value (); @@ -3924,7 +3937,7 @@ pass_vsetvl::cleanup_insns (void) const if (!has_vl_op (rinsn) || !REG_P (get_vl (rinsn))) continue; rtx avl = get_vl (rinsn); - if (count_occurrences (PATTERN (rinsn), avl, 0) == 1) + if (count_regno_occurrences (rinsn, REGNO (avl)) == 1) { /* Get the list of uses for the new instruction. */ auto attempt = crtl->ssa->new_change_attempt ();