[llvm] [RISCV] Add XSfmm pseudo instruction and vset* insertion support (PR #143068)

Brandon Wu via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 7 21:08:37 PDT 2025


================
@@ -1774,6 +1886,80 @@ void RISCVInsertVSETVLI::insertReadVL(MachineBasicBlock &MBB) {
   }
 }
 
+static void shrinkIntervalAndRemoveDeadMI(MachineOperand &MO,
+                                          LiveIntervals *LIS) {
+  Register Reg = MO.getReg();
+  MO.setReg(RISCV::NoRegister);
+  MO.setIsKill(false);
+
+  if (!LIS)
+    return;
+
+  LiveInterval &LI = LIS->getInterval(Reg);
+
+  // Erase the AVL operand from the instruction.
+  SmallVector<MachineInstr *> DeadMIs;
+  LIS->shrinkToUses(&LI, &DeadMIs);
+  // TODO: Enable this once needVSETVLIPHI is supported.
+  // SmallVector<LiveInterval *> SplitLIs;
+  // LIS->splitSeparateComponents(LI, SplitLIs);
+
+  for (MachineInstr *DeadMI : DeadMIs) {
+    LIS->RemoveMachineInstrFromMaps(*DeadMI);
----------------
4vtomat wrote:

I think we are not able to test this right now because we are emitting all of vset* no matter it needs or not

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


More information about the llvm-commits mailing list