[llvm] [VPlan] Simplify Plan's entry in removeBranchOnConst. (PR #154510)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 05:52:39 PDT 2025


================
@@ -1927,7 +1927,7 @@ void VPlanTransforms::removeBranchOnConst(VPlan &Plan) {
   for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
            vp_depth_first_shallow(Plan.getEntry()))) {
     VPValue *Cond;
-    if (VPBB->getNumSuccessors() != 2 || VPBB == Plan.getEntry() ||
+    if (VPBB->getNumSuccessors() != 2 || VPBB->empty() ||
----------------
ayalz wrote:

Understood, plus even w/ a pair of successors VPBB may be empty. Is it then (necessary and) suffice to check
```
    if (VPBB->empty() ||
        !match(&VPBB->back(), m_BranchOnCond(m_VPValue(Cond))))
      continue;

    assert(VPBB->getNumSuccessors() == 2 && "Two successors expected for BranchOnCond"); 
```
but redundant first check for two-successors may early-continue faster?

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


More information about the llvm-commits mailing list