aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2024-06-23 20:11:36 +0100
committerFlorian Hahn <flo@fhahn.com>2024-06-23 20:11:37 +0100
commitab9c2b1c54392e20d0b14d3b009146f8d68d192f (patch)
treeb5ef9c21bf9a224af7dd022f0a52765375ede7cc
parent05d167fc201b4f2e96108be0d682f6800a70c23d (diff)
downloadllvm-ab9c2b1c54392e20d0b14d3b009146f8d68d192f.zip
llvm-ab9c2b1c54392e20d0b14d3b009146f8d68d192f.tar.gz
llvm-ab9c2b1c54392e20d0b14d3b009146f8d68d192f.tar.bz2
[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 https://github.com/llvm/llvm-project/pull/92651.
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index a3ff639..a4a1150 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -442,20 +442,20 @@ Value *VPInstruction::generatePerPart(VPTransformState &State, unsigned Part) {
return nullptr;
Value *Cond = State.get(getOperand(0), VPIteration(Part, 0));
- VPRegionBlock *ParentRegion = getParent()->getParent();
- VPBasicBlock *Header = ParentRegion->getEntryBasicBlock();
-
// Replace the temporary unreachable terminator with a new conditional
// branch, hooking it up to backward destination for exiting blocks now and
// to forward destination(s) later when they are created.
BranchInst *CondBr =
Builder.CreateCondBr(Cond, Builder.GetInsertBlock(), nullptr);
-
- if (getParent()->isExiting())
- CondBr->setSuccessor(1, State.CFG.VPBB2IRBB[Header]);
-
CondBr->setSuccessor(0, nullptr);
Builder.GetInsertBlock()->getTerminator()->eraseFromParent();
+
+ if (!getParent()->isExiting())
+ return CondBr;
+
+ VPRegionBlock *ParentRegion = getParent()->getParent();
+ VPBasicBlock *Header = ParentRegion->getEntryBasicBlock();
+ CondBr->setSuccessor(1, State.CFG.VPBB2IRBB[Header]);
return CondBr;
}
case VPInstruction::BranchOnCount: {