From patchwork Fri Jun 16 07:59:16 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: 108918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1159064vqr; Fri, 16 Jun 2023 00:59:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qYI/XTaX0bZNIkKF9TRGs86asfsLGMCF0fizFyvtSuXF0EA4lg6oX77R2GRiVF/eubF3u X-Received: by 2002:a19:5f11:0:b0:4f6:2e5f:45cc with SMTP id t17-20020a195f11000000b004f62e5f45ccmr679610lfb.3.1686902393407; Fri, 16 Jun 2023 00:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686902393; cv=none; d=google.com; s=arc-20160816; b=Ggmmv7PQ3hlmEjgV68Wps35nntUbQEQu7oqMpnwJIIWdW/XVuhKpDiPjUgmnkD0Jf/ 5rywcKibMdRxaPX08SYkgWFd8UUbKQBNKQL623ZgTdEETqepO2Hi6gr/kPdgog6hUWot Y//1w3s7HYkFGMu5ezcm7wPd6MEaoPlsSCoVSJ4c5WgClRIIl0wK8EjxWPTw4tl1D8lO m4txeEyPwVLNLhnbxnuVqPZSvfLJwutdsuwckCc29H1B8lYHwkmWqMn33QiOrgKbiXYm lGV4uoWpAJiUv+ZFa/JltgpIfTcGKdWDS/Jzhp1/WK5h7qRZUZhx10vJE7YxwXXryUDl WExg== 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=8AI7RrHzX6FApt/5qZh1bETn1gl5G4Sm71kY7de7kB8=; b=CLqgK+7a0e7Vh4gRBm1t0sa5jebkL0lfE2tsOYYcDB9nF2fvjtEIZtE34of+6kD483 pL5blDz9dCvj4cuUznJCI86/Gt6VEpDDL42GgVEnrZGSz4l+9l0C8L7B6E988Jq8WBWI To7Xejg1oTjdjzj1bi7pYPMR/7SX8r3eU1xARWzWUdt+NqlWg6OiE6Zoq/Ag2mSaR8ot DM23KTPYdqnwjg7Fv6FgqC1py6hlpsqXTkKPZms1WY2FFxR6NxybutCIESSOeSG6EbwK XDm3BiVMXFbp7sWDd0PlAsjwsZ6dmNmxYkm39BayhjcOSoJez3ldMLdUvM2q8iWXMoZ5 koaw== 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i6-20020a1709063c4600b009823a26c3c6si5101930ejg.770.2023.06.16.00.59.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 00:59:53 -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 71E383853D3C for ; Fri, 16 Jun 2023 07:59:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by sourceware.org (Postfix) with ESMTPS id EC0D038555A4 for ; Fri, 16 Jun 2023 07:59:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC0D038555A4 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: bizesmtp80t1686902358tjjli48x Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 16 Jun 2023 15:59:17 +0800 (CST) X-QQ-SSF: 01400000000000G0S000000A0000000 X-QQ-FEAT: 0vfWcIgh24xJABm9rONXQ2v8xvS7vew/VXx0j77XXG1XSLXKMLZeKQSqQ336t WoDQ+NsfDRGzukvxyMetOazqBCALm1r5IrgfrFE1RvaVpbK/eqxa7tyJBUBnAnsZlPxQG2r uVzQ+qebwOTWUbRnj0yN3nMluTJ62Gjt1nrH4v9gBPre7DxLCiOGswkxuICZSE+jjQi/Gk3 6fPkw5IySK/kO1WvYv45AN+QkkwXoXJRY/Ro3Icibs9Ws66nWdDApJ+GitG1ynkFq1wozOn VRnlZ3R/qExhXGTOvbEcL9GB/BqaoolIOcxQpONVOT2R61PNc2jeQ75FwPGnPg25BtQBxW6 c46mJUxWwnTnX2qaSb5HBVfz7rKLCBL2eFp8xjGQak0Q18VAs2hqWIj2q8hmL+DN3kjelfI cwa/8E0nBk0= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 12072532553525370467 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, palmer@dabbelt.com, palmer@rivosinc.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Fix PR 110264 Date: Fri, 16 Jun 2023 15:59:16 +0800 Message-Id: <20230616075916.141968-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:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 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?1768845364331242154?= X-GMAIL-MSGID: =?utf-8?q?1768845364331242154?= This patch fixes this issue happens on both GCC-13 and GCC-14. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110264 The testcase is too big and I failed to reduce it so I didn't append test into this patch. This patch should not only land into GCC-14 but also should backport to GCC-13. gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (insert_vsetvl): Fix bug. --- gcc/config/riscv/riscv-vsetvl.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index cae9be0d928..42cc6f29f26 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -744,7 +744,10 @@ insert_vsetvl (enum emit_type emit_type, rtx_insn *rinsn, if (vlmax_avl_p (info.get_avl ())) { gcc_assert (has_vtype_op (rinsn) || vsetvl_insn_p (rinsn)); - rtx vl_op = info.get_avl_reg_rtx (); + /* For user vsetvli a5, zero, we should use get_vl to get the VL + operand "a5". */ + rtx vl_op + = vsetvl_insn_p (rinsn) ? get_vl (rinsn) : info.get_avl_reg_rtx (); gcc_assert (!vlmax_avl_p (vl_op)); emit_vsetvl_insn (VSETVL_NORMAL, emit_type, info, vl_op, rinsn); return VSETVL_NORMAL;