[llvm] [CodeGen] Fix partial phi input removal in TailDuplicator. (PR #158265)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 03:51:11 PDT 2025


================
@@ -375,9 +375,14 @@ void TailDuplicator::processPHI(
   if (!Remove)
     return;
 
-  // Remove PredBB from the PHI node.
-  MI->removeOperand(SrcOpIdx + 1);
-  MI->removeOperand(SrcOpIdx);
+  // MI might have multiple entries for PredBB. Need to remove them all.
+  for (unsigned N = MI->getNumOperands(); N > 2; N -= 2) {
----------------
arsenm wrote:

I thought there was a helper for this somewhere? The IR has one, and isn't there one used in the MachineBasicBlock CFG helpers? 

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


More information about the llvm-commits mailing list