[llvm] [LV] Vectorize uncountable early exit store loops with combined conditions (PR #205109)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 07:54:05 PDT 2026


================
@@ -3234,6 +3234,61 @@ bool VPlanTransforms::handleUncountableEarlyExits(
     }
   }
 
+  // Retrieve the latch branch and its condition; this is expected to be either
+  // a counted condition, or a combination of counted and uncounted conditions.
+  auto *LatchExitingBranch = cast<VPInstruction>(LatchVPBB->getTerminator());
+  assert(LatchExitingBranch->getOpcode() == VPInstruction::BranchOnCond &&
+         "Unexpected terminator");
+  VPValue *IsLatchExitTaken = LatchExitingBranch->getOperand(0);
+  VPInstruction *OldCombinedBranchCondition = nullptr;
+
+  // If we didn't find any uncounted exits with exit paths not involving the
+  // middle block, perhaps the exit was combined in the latch.
+  if (Exits.empty() && Plan.getExitBlocks().size() == 1) {
+    // TODO: Make this work with other styles.
+    if (Style != UncountableExitStyle::MaskedHandleExitInScalarLoop)
----------------
fhahn wrote:

Not sure if that would work out, but as alternative, could we convert the OR condition back to CFG before we perform the early-exit handling? that way it should work for all styles?

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


More information about the llvm-commits mailing list