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

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 29 02:36:43 PST 2025


================
@@ -592,30 +592,31 @@ 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 IsBranchOnTwoConds = match(R, m_BranchOnTwoConds());
+  [[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 || IsBranchOnTwoConds) &&
            "block with multiple successors not terminated by "
            "conditional branch nor switch recipe");
 
     return true;
   }
 
   if (VPBB->getNumSuccessors() > 2) {
-    assert(IsSwitch && "block with more than 2 successors not terminated by "
-                       "a switch recipe");
+    assert((IsSwitch || IsBranchOnTwoConds) &&
+           "block with more than 2 successors not terminated by "
+           "a switch or branch-on-two-conds recipe");
----------------
ayalz wrote:

```suggestion
           "block with more than 2 successors not terminated by a switch or"
           "branch-on-two-conds recipe");
```

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


More information about the llvm-commits mailing list