[IR] improve code comment/logic in removePredecessor(); NFC

This was suggested in the post-commit review of ce134da4b1.
This commit is contained in:
Sanjay Patel 2020-11-30 10:49:40 -05:00
parent e0e7bbeb54
commit 1dc38f8cfb
1 changed files with 9 additions and 7 deletions

View File

@ -333,14 +333,16 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
Phi.removeIncomingValue(Pred, !KeepOneInputPHIs);
if (KeepOneInputPHIs)
continue;
// If we have a single predecessor, removeIncomingValue erased the PHI
// node itself.
// If we have a single predecessor, removeIncomingValue may have erased the
// PHI node itself.
if (NumPreds == 1)
continue;
// Try to replace the PHI node with a constant value.
if (NumPreds > 1) {
if (Value *PhiConstant = Phi.hasConstantValue()) {
Phi.replaceAllUsesWith(PhiConstant);
Phi.eraseFromParent();
}
if (Value *PhiConstant = Phi.hasConstantValue()) {
Phi.replaceAllUsesWith(PhiConstant);
Phi.eraseFromParent();
}
}
}