[llvm] [LV] Vectorize early exit loops with stores using masking (PR #178454)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 05:59:02 PDT 2026


================
@@ -3981,6 +3982,20 @@ void VPlanTransforms::expandBranchOnTwoConds(VPlan &Plan) {
     VPBlockBase *Succ0 = Successors[0];
     VPBlockBase *Succ1 = Successors[1];
     VPBlockBase *Succ2 = Successors[2];
+
+    // If the successor block for both conditions is the same, then combine the
+    // two conditions and plant a single conditional branch.
+    if (Succ0 == Succ1) {
+      DebugLoc BrDL = Br->getDebugLoc();
+      VPBuilder Builder(Br);
+      VPValue *Combined = Builder.createOr(Cond0, Cond1, BrDL);
+      Builder.createNaryOp(VPInstruction::BranchOnCond, {Combined}, BrDL);
+      VPBlockUtils::connectBlocks(BrOnTwoCondsBB, Succ0);
+      VPBlockUtils::connectBlocks(BrOnTwoCondsBB, Succ2);
+      Br->eraseFromParent();
+      return;
----------------
huntergr-arm wrote:

done.

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


More information about the llvm-commits mailing list