[llvm] [RISCV] Remove VMConstraint from ri.vzero.v (PR #181895)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 17 12:19:35 PST 2026


https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/181895

>From 1d9bbb1351d6be38c0a08a6dfc87403fda4f8188 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 17 Feb 2026 12:10:54 -0800
Subject: [PATCH 1/2] [RISCV] Remove VMConstraint from ri.vzero.v

This instruction doesn't have a VM operand.

It only has 1 operand, VD. The way the VMConstraint check is
implemented, if VD is V0 it would compare the last operand to V0.
Since the last operand is VD, this would always match and generate
an error.

While I was here, move the encoding related let statements into
the class body for consistency with RISCVInstrInfoV.td.
---
 llvm/lib/Target/RISCV/RISCVInstrInfoXRivos.td | 12 +++++++++---
 llvm/test/MC/RISCV/xrivosvisni-valid.s        |  3 +++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXRivos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXRivos.td
index daf8550e4cb45..51506f40d3811 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXRivos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXRivos.td
@@ -117,10 +117,16 @@ defm : RIVPatBinaryVL_VV<ri_vunzip2b_vl, "PseudoRI_VUNZIP2B">;
 let Predicates = [HasVendorXRivosVisni], DecoderNamespace = "XRivos",
   mayLoad = false, mayStore = false, hasSideEffects = false in {
 
-let vm = 0, vs2=0, Inst<6-0> = OPC_CUSTOM_2.Value,
-    isReMaterializable = 1, isAsCheapAsAMove = 1 in
+let isReMaterializable = 1, isAsCheapAsAMove = 1 in
 def RI_VZERO : RVInstVUnary<0b000000, 0b00000, OPCFG, (outs VR:$vd),
-                            (ins), "ri.vzero.v", "$vd">;
+                            (ins), "ri.vzero.v", "$vd"> {
+  let vm = 0;
+  let vs2 = 0;
+
+  let Inst{6-0} = OPC_CUSTOM_2.Value;
+
+  let RVVConstraint = NoConstraint;
+}
 
 def RI_VINSERT : CustomRivosVXI<0b010000, OPMVX, (outs VR:$vd_wb),
                                 (ins VR:$vd, GPR:$rs1, uimm5:$imm),
diff --git a/llvm/test/MC/RISCV/xrivosvisni-valid.s b/llvm/test/MC/RISCV/xrivosvisni-valid.s
index 234545721eaf5..69f262027b1e0 100644
--- a/llvm/test/MC/RISCV/xrivosvisni-valid.s
+++ b/llvm/test/MC/RISCV/xrivosvisni-valid.s
@@ -9,6 +9,9 @@
 # RUN:     | llvm-objdump --mattr=+experimental-xrivosvisni -M no-aliases --no-print-imm-hex -d -r - \
 # RUN:     | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 
+# CHECK-ASM-AND-OBJ: ri.vzero.v v1
+# CHECK-ASM: encoding: [0xdb,0x70,0x00,0x00]
+ri.vzero.v v0
 # CHECK-ASM-AND-OBJ: ri.vzero.v v1
 # CHECK-ASM: encoding: [0xdb,0x70,0x00,0x00]
 ri.vzero.v v1

>From 193fbbda9e5633b820e810995f55aac4fc55471c Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 17 Feb 2026 12:19:14 -0800
Subject: [PATCH 2/2] fixup! update test checks

---
 llvm/test/MC/RISCV/xrivosvisni-valid.s | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/MC/RISCV/xrivosvisni-valid.s b/llvm/test/MC/RISCV/xrivosvisni-valid.s
index 69f262027b1e0..9dbea6ecb5905 100644
--- a/llvm/test/MC/RISCV/xrivosvisni-valid.s
+++ b/llvm/test/MC/RISCV/xrivosvisni-valid.s
@@ -9,8 +9,8 @@
 # RUN:     | llvm-objdump --mattr=+experimental-xrivosvisni -M no-aliases --no-print-imm-hex -d -r - \
 # RUN:     | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 
-# CHECK-ASM-AND-OBJ: ri.vzero.v v1
-# CHECK-ASM: encoding: [0xdb,0x70,0x00,0x00]
+# CHECK-ASM-AND-OBJ: ri.vzero.v v0
+# CHECK-ASM: encoding: [0x5b,0x70,0x00,0x00]
 ri.vzero.v v0
 # CHECK-ASM-AND-OBJ: ri.vzero.v v1
 # CHECK-ASM: encoding: [0xdb,0x70,0x00,0x00]



More information about the llvm-commits mailing list