[llvm] [RISCV] Correct the register class for the VL op check in RISCVInstrInfo::verifyInstruction. (PR #170751)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 4 13:46:32 PST 2025


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/170751

The VL operand cannot be X0. We represent VLMAX with -1.

>From e85d76433c0fb105b082bbfc2e4786f7e90043af Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 4 Dec 2025 13:44:09 -0800
Subject: [PATCH] [RISCV] Correct the register class for the VL op check in
 RISCVInstrInfo::verifyInstruction.

The VL operand cannot be X0. We represent VLMAX with -1.
---
 llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 2bd63e75d060b..3bd333b9f9414 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -3063,7 +3063,7 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
     if (Op.isReg() && Op.getReg().isValid()) {
       const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
       auto *RC = MRI.getRegClass(Op.getReg());
-      if (!RISCV::GPRRegClass.hasSubClassEq(RC)) {
+      if (!RISCV::GPRNoX0RegClass.hasSubClassEq(RC)) {
         ErrInfo = "Invalid register class for VL operand";
         return false;
       }



More information about the llvm-commits mailing list