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

Afanasyev Ivan via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 03:55:55 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) {
----------------
ivafanas wrote:

I've run grep by `getMBB()` and seems like there is no helper. PHI input removal code is seems to be re-implemented from scratch each time (or copy-pasted)

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


More information about the llvm-commits mailing list