[llvm] [VPlan] Add BranchOnMultiCond, use for early exit plans. (PR #172750)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 23 14:26:21 PST 2025


================
@@ -592,25 +592,26 @@ static bool hasConditionalTerminator(const VPBasicBlock *VPBB) {
   }
 
   const VPRecipeBase *R = &VPBB->back();
-  bool IsSwitch = isa<VPInstruction>(R) &&
-                  cast<VPInstruction>(R)->getOpcode() == Instruction::Switch;
-  bool IsCondBranch =
+  [[maybe_unused]] bool IsSwitch =
+      isa<VPInstruction>(R) &&
+      cast<VPInstruction>(R)->getOpcode() == Instruction::Switch;
+  [[maybe_unused]] bool IsBranchOnMultiCond = match(R, m_BranchOnMultiCond());
+  [[maybe_unused]] bool IsCondBranch =
       isa<VPBranchOnMaskRecipe>(R) ||
       match(R, m_CombineOr(m_BranchOnCond(), m_BranchOnCount()));
-  (void)IsCondBranch;
-  (void)IsSwitch;
   if (VPBB->getNumSuccessors() == 2 ||
       (VPBB->isExiting() && !VPBB->getParent()->isReplicator())) {
-    assert((IsCondBranch || IsSwitch) &&
+    assert((IsCondBranch || IsSwitch || IsBranchOnMultiCond) &&
            "block with multiple successors not terminated by "
            "conditional branch nor switch recipe");
----------------
fhahn wrote:

I think we also check in the verifier, but the verifier doesn't run that frequently, which I think is why we added the assertions here.

(Could also switch back to the previous

``` 
- (void)IsSwitch;
- (void)IsCondBranch;
```

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


More information about the llvm-commits mailing list