llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Cleanup some messy iterator work.

Co-Authored-By: Claude Opus 5 &lt;noreply@<!-- -->anthropic.com&gt;

---
Full diff: https://github.com/llvm/llvm-project/pull/227296.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/TwoAddressInstructionPass.cpp (+7-6) 


``````````diff
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp 
b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 9ec96c180a0c1..ee2372e71e297 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -1066,12 +1066,13 @@ bool TwoAddressInstructionImpl::rescheduleMIBelowKill(
     // We have to move the copies (and any interleaved debug instructions)
     // first so that the MBB is still well-formed when calling handleMove().
     // Move them back to front, so a copy never ends up above its source def.
-    for (MachineBasicBlock::iterator MIIt(MI); std::next(MIIt) != End;) {
-      MachineBasicBlock::iterator CopyMI = std::prev(End);
-      MBB->splice(InsertPos, MBB, CopyMI);
-      if (!CopyMI->isDebugOrPseudoInstr())
-        LIS->handleMove(*CopyMI);
-      InsertPos = CopyMI;
+    auto Copies = make_range(MachineBasicBlock::reverse_iterator(End),
+                             MachineBasicBlock::reverse_iterator(AfterMI));
+    for (MachineInstr &CopyMI : make_early_inc_range(Copies)) {
+      MBB->splice(InsertPos, MBB, &CopyMI);
+      if (!CopyMI.isDebugOrPseudoInstr())
+        LIS->handleMove(CopyMI);
+      InsertPos = &CopyMI;
     }
     End = std::next(MachineBasicBlock::iterator(MI));
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/227296
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to