[llvm] [RISCV] Add register overlap checks to the assembler for vector indexed segment load (PR #184569)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 01:38:18 PST 2026
https://github.com/joshua-arch1 updated https://github.com/llvm/llvm-project/pull/184569
>From 5d87817b9851b1fbe30a6e35dfaedbd400103a23 Mon Sep 17 00:00:00 2001
From: joshua-arch1 <cooper.joshua at linux.alibaba.com>
Date: Wed, 4 Mar 2026 17:37:49 +0800
Subject: [PATCH] [RISCV] Add register overlap checks to the assembler for
vector indexed segment load
---
llvm/lib/Target/RISCV/RISCVInstrInfoV.td | 2 +
llvm/test/MC/RISCV/rvv/zvlsseg-invalid.s | 122 +++++++++++++++++++++++
2 files changed, 124 insertions(+)
create mode 100644 llvm/test/MC/RISCV/rvv/zvlsseg-invalid.s
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
index bb8d26662ae4e..2426a3858d154 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
@@ -409,6 +409,7 @@ class VStridedSegmentLoad<int nfields, RISCVWidth width, string opcodestr>
}
// indexed segment load vd, (rs1), vs2, vm
+let VS1VS2Constraint = VS1Constraint in {
class VIndexedSegmentLoad<int nfields, RISCVMOP mop, RISCVWidth width,
string opcodestr>
: RVInstVLX<!sub(nfields, 1), width, mop, (outs VR:$vd),
@@ -416,6 +417,7 @@ class VIndexedSegmentLoad<int nfields, RISCVMOP mop, RISCVWidth width,
"$vd, $rs1, $vs2$vm"> {
assert !and(!ge(nfields, 2), !le(nfields, 8)), "nfields must be 2-8";
}
+} // VS1VS2Constraint = VS1Constraint
} // hasSideEffects = 0, mayLoad = 1, mayStore = 0
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
diff --git a/llvm/test/MC/RISCV/rvv/zvlsseg-invalid.s b/llvm/test/MC/RISCV/rvv/zvlsseg-invalid.s
new file mode 100644
index 0000000000000..cd7314dc30da5
--- /dev/null
+++ b/llvm/test/MC/RISCV/rvv/zvlsseg-invalid.s
@@ -0,0 +1,122 @@
+# RUN: not llvm-mc -triple=riscv64 --mattr=+v %s 2>&1 \
+# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
+
+vluxseg2ei8.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei8.v v8, (a0), v8, v0.t
+
+vluxseg2ei8.v v8, (a0), v9, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei8.v v8, (a0), v9, v0.t
+
+vluxseg3ei8.v v8, (a0), v10, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg3ei8.v v8, (a0), v10, v0.t
+
+vluxseg4ei8.v v8, (a0), v11, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg4ei8.v v8, (a0), v11, v0.t
+
+vluxseg5ei8.v v8, (a0), v12, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg5ei8.v v8, (a0), v12, v0.t
+
+vluxseg6ei8.v v8, (a0), v13, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg6ei8.v v8, (a0), v13, v0.t
+
+vluxseg7ei8.v v8, (a0), v14, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg7ei8.v v8, (a0), v14, v0.t
+
+vluxseg8ei8.v v8, (a0), v15, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg8ei8.v v8, (a0), v15, v0.t
+
+vluxseg2ei8.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei8.v v8, (a0), v8
+
+vluxseg2ei16.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei16.v v8, (a0), v8, v0.t
+
+vluxseg2ei16.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei16.v v8, (a0), v8
+
+vluxseg2ei32.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei32.v v8, (a0), v8, v0.t
+
+vluxseg2ei32.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei32.v v8, (a0), v8
+
+vluxseg2ei64.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei64.v v8, (a0), v8, v0.t
+
+vluxseg2ei64.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vluxseg2ei64.v v8, (a0), v8
+
+vloxseg2ei8.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei8.v v8, (a0), v8, v0.t
+
+vloxseg2ei8.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei8.v v8, (a0), v8
+
+vloxseg2ei16.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei16.v v8, (a0), v8, v0.t
+
+vloxseg2ei16.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei16.v v8, (a0), v8
+
+vloxseg2ei32.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei32.v v8, (a0), v8, v0.t
+
+vloxseg2ei32.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei32.v v8, (a0), v8
+
+vloxseg2ei64.v v8, (a0), v8, v0.t
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei64.v v8, (a0), v8, v0.t
+
+vloxseg2ei64.v v8, (a0), v8
+# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group
+# CHECK-ERROR-LABEL: vloxseg2ei64.v v8, (a0), v8
+
+vluxseg2ei8.v v31, (a0), v10, v0.t
+# CHECK-ERROR: All the vector registers in the group must be within V0-V31.
+# CHECK-ERROR-LABEL: vluxseg2ei8.v v31, (a0), v10, v0.t
+
+vsuxseg2ei8.v v31, (a0), v10, v0.t
+# CHECK-ERROR: All the vector registers in the group must be within V0-V31.
+# CHECK-ERROR-LABEL: vsuxseg2ei8.v v31, (a0), v10, v0.t
+
+vlseg2e8.v v31, (a0), v0.t
+# CHECK-ERROR: All the vector registers in the group must be within V0-V31.
+# CHECK-ERROR-LABEL: vlseg2e8.v v31, (a0), v0.t
+
+vlsseg2e8.v v31, (a0), a1, v0.t
+# CHECK-ERROR: All the vector registers in the group must be within V0-V31.
+# CHECK-ERROR-LABEL: vlsseg2e8.v v31, (a0), a1, v0.t
+
+vlseg2e8ff.v v31, (a0), v0.t
+# CHECK-ERROR: All the vector registers in the group must be within V0-V31.
+# CHECK-ERROR-LABEL: vlseg2e8ff.v v31, (a0), v0.t
+
+vsseg2e8.v v31, (a0), v0.t
+# CHECK-ERROR: All the vector registers in the group must be within V0-V31.
+# CHECK-ERROR-LABEL: vsseg2e8.v v31, (a0), v0.t
+
+vssseg2e8.v v31, (a0), a1, v0.t
+# CHECK-ERROR: All the vector registers in the group must be within V0-V31.
+# CHECK-ERROR-LABEL: vssseg2e8.v v31, (a0), a1, v0.t
More information about the llvm-commits
mailing list