[llvm] [RISCV][VLOPT] Support segmented store instructions (PR #155467)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 23:32:32 PDT 2025


================
@@ -1376,6 +1405,83 @@ RISCVVLOptimizer::getMinimumVLForUser(const MachineOperand &UserOp) const {
   return VLOp;
 }
 
+/// Return true if MI is an instruction used for assembling registers
+/// for segmented store instructions, namely, RISCVISD::TUPLE_INSERT.
+/// Currently it's lowered to INSERT_SUBREG.
+static bool isTupleInsertInstr(const MachineInstr &MI,
+                               const MachineRegisterInfo &MRI) {
+  if (MI.getOpcode() != RISCV::INSERT_SUBREG)
+    return false;
+
+  const TargetRegisterClass *DstRC = MRI.getRegClass(MI.getOperand(0).getReg());
+  // Check whether it was lowered with the correct subreg index.
+  [[maybe_unused]] const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
+  [[maybe_unused]] unsigned SubRegIdx = MI.getOperand(3).getImm();
+  switch (DstRC->getID()) {
+  case RISCV::VRN2M1RegClassID:
----------------
wangpc-pp wrote:

Maybe we can just read the NF/LMUL in `TargetRegisterRegister.TSFlags`?

https://github.com/llvm/llvm-project/pull/155467


More information about the llvm-commits mailing list