Skip to content

Commit 26aaf73

Browse files
fhahnAlexisPerry
authored andcommitted
[VPlan] Restructure code for BranchOnCond codegen. (NFCI)
Reoder code to exit early if the BranchOnCond isn't in an exiting block. This delays retrieving the parent region, which may not be present. Split off from llvm#92651.
1 parent 0ef5525 commit 26aaf73

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,20 @@ Value *VPInstruction::generatePerPart(VPTransformState &State, unsigned Part) {
442442
return nullptr;
443443

444444
Value *Cond = State.get(getOperand(0), VPIteration(Part, 0));
445-
VPRegionBlock *ParentRegion = getParent()->getParent();
446-
VPBasicBlock *Header = ParentRegion->getEntryBasicBlock();
447-
448445
// Replace the temporary unreachable terminator with a new conditional
449446
// branch, hooking it up to backward destination for exiting blocks now and
450447
// to forward destination(s) later when they are created.
451448
BranchInst *CondBr =
452449
Builder.CreateCondBr(Cond, Builder.GetInsertBlock(), nullptr);
453-
454-
if (getParent()->isExiting())
455-
CondBr->setSuccessor(1, State.CFG.VPBB2IRBB[Header]);
456-
457450
CondBr->setSuccessor(0, nullptr);
458451
Builder.GetInsertBlock()->getTerminator()->eraseFromParent();
452+
453+
if (!getParent()->isExiting())
454+
return CondBr;
455+
456+
VPRegionBlock *ParentRegion = getParent()->getParent();
457+
VPBasicBlock *Header = ParentRegion->getEntryBasicBlock();
458+
CondBr->setSuccessor(1, State.CFG.VPBB2IRBB[Header]);
459459
return CondBr;
460460
}
461461
case VPInstruction::BranchOnCount: {

0 commit comments

Comments
 (0)