[llvm-branch-commits] [llvm] CodeGen: Handle bundled instructions in two-address-instructions pass (PR #166212)

Nicolai Hähnle via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Nov 6 09:03:57 PST 2025


================
@@ -1665,6 +1665,22 @@ void TwoAddressInstructionImpl::processTiedPairs(MachineInstr *MI,
     // by SubRegB is compatible with RegA with no subregister. So regardless of
     // whether the dest oper writes a subreg, the source oper should not.
     MO.setSubReg(0);
+
+    // Update uses of RegB to uses of RegA inside the bundle.
+    if (MI->isBundle()) {
+      for (MachineInstr *InnerMI = MI; InnerMI->isBundledWithSucc();) {
+        InnerMI = InnerMI->getNextNode();
+
+        for (MachineOperand &MO : InnerMI->all_uses()) {
+          if (MO.isReg() && MO.getReg() == RegB) {
+            assert(
+                MO.getSubReg() == 0 &&
+                "tied subregister uses in bundled instructions not supported");
+            MO.setReg(RegA);
----------------
nhaehnle wrote:

I played around with this but it got very confusing to me even in the restricted use case that I described in the other comment. I'd prefer to just keep this more restrictive for now, and if we find later on that supporting subregisters is beneficial we relax it separately.

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


More information about the llvm-branch-commits mailing list