[llvm] [VPlan] Replace VPRegionBlock with explicit CFG before execute (NFCI). (PR #117506)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 04:37:55 PDT 2025


================
@@ -576,18 +576,17 @@ Value *VPInstruction::generate(VPTransformState &State) {
   case VPInstruction::BranchOnCond: {
     Value *Cond = State.get(getOperand(0), VPLane(0));
     // 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.
+    // branch, hooking it up to backward destination (header) for latch blocks
+    // now, and to forward destination(s) later when they are created.
----------------
ayalz wrote:

Could this be more consistent with BranchOnCount below, as in
```suggestion
    // now, and to forward destination(s) later when they are created.
    // Second successor may be backwards - iff it is already in VPBB2IRBB.
    VPBasicBlock *SecondVPSucc = cast<VPBasicBlock>(getParent()->getSuccessors()[1]);
    BasicBlock *SecondIRSucc = State.CFG.VPBB2IRBB.lookup(SecondVPSucc);
    // Note that CreateCondBr expects a valid BB as first argument, but first successor is always forwards, so we reset it to nullptr.
    BranchInst *CondBr =
        Builder.CreateCondBr(Cond, Builder.GetInsertBlock(), SecondIRSucc);
    CondBr->setSuccessor(0, nullptr);
```

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


More information about the llvm-commits mailing list