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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed May 20 05:05:46 PDT 2026


================
@@ -4215,8 +4376,24 @@ void VPlanTransforms::handleUncountableEarlyExits(VPlan &Plan,
   VPValue *IsAnyExitTaken =
       Builder.createNaryOp(VPInstruction::AnyOf, {Combined});
 
-  assert(Style == UncountableExitStyle::ReadOnly &&
-         "Early exit store masking not implemented");
+  if (Style == UncountableExitStyle::MaskedHandleExitInScalarLoop) {
+    auto *LatchExitingBranch = cast<VPInstruction>(LatchVPBB->getTerminator());
+    assert(LatchExitingBranch->getOpcode() == VPInstruction::BranchOnCount &&
+           "Unexpected terminator");
+    auto *IsLatchExitTaken =
+        Builder.createICmp(CmpInst::ICMP_EQ, LatchExitingBranch->getOperand(0),
+                           LatchExitingBranch->getOperand(1));
+
----------------
lukel97 wrote:

I don't suppose there's a way to share this IsLatchExitTaken with the original one in line 4525?

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


More information about the llvm-commits mailing list