[llvm] [VPlan] Simplify branch on False in VPlan transform (NFC). (PR #140409)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 29 14:14:33 PDT 2025
================
@@ -2379,13 +2379,15 @@ void InnerLoopVectorizer::introduceCheckBlockInVPlan(BasicBlock *CheckIRBB) {
PreVectorPH->swapSuccessors();
// We just connected a new block to the scalar preheader. Update all
- // ResumePhis by adding an incoming value for it, replicating the last value.
- for (VPRecipeBase &R : *cast<VPBasicBlock>(ScalarPH)) {
- auto *ResumePhi = dyn_cast<VPInstruction>(&R);
- if (!ResumePhi || ResumePhi->getOpcode() != VPInstruction::ResumePhi)
- continue;
+ // VPPhis by adding an incoming value for it, replicating the last value.
+ unsigned NumPredecessors = ScalarPH->getNumPredecessors();
+ (void)NumPredecessors;
+ for (VPRecipeBase &R : cast<VPBasicBlock>(ScalarPH)->phis()) {
+ auto *ResumePhi = cast<VPPhi>(&R);
ResumePhi->addOperand(
ResumePhi->getOperand(ResumePhi->getNumOperands() - 1));
+ assert(ResumePhi->getNumIncoming() == NumPredecessors &&
+ "must have incoming values for all operands");
----------------
ayalz wrote:
```suggestion
for (VPRecipeBase &R : cast<VPBasicBlock>(ScalarPH)->phis()) {
assert(isa<VPPhi>(&R) && "Phi expected to be VPPhi");
assert(cast<VPPhi>(&R)->getNumIncoming() == NumPredecessors - 1 &&
"must have incoming values for all operands");
R->addOperand(R->getOperand(NumPredecessors - 1));
```
https://github.com/llvm/llvm-project/pull/140409
More information about the llvm-commits
mailing list