[llvm] [PeepholeOptimizer] Add REG_SEQUENCE subregister use folding (PR #205795)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 04:48:27 PDT 2026


================
@@ -614,6 +614,21 @@ class LLVM_ABI TargetInstrInfo : public MCInstrInfo {
         : RegSubRegPair(Reg, SubReg), SubIdx(SubIdx) {}
   };
 
+  /// Check if \p MO can be used as operand \p OpIdx for \p MI.
+  ///
+  /// \param MI    The instruction to validate against.
+  /// \param OpIdx The operand position to check.
+  /// \param MO    The operand to validate. Does not need to have a parent.
+  ///              If nullptr, checks MI.getOperand(OpIdx).
+  ///
+  /// \returns true if the operand would be legal at the given position.
+  ///
+  /// \note The generic implementation returns true.
+  virtual bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
+                              const MachineOperand *MO) const {
+    return true;
+  }
----------------
arsenm wrote:

This should not be necessary. The relevant compatibility rules are already expressible in terms of RegisterClass and subregister Indices 

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


More information about the llvm-commits mailing list