[llvm] [LV] Check if the VF is scalar by VFRange in `handleUncountableEarlyExit`. (PR #135294)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 15 01:08:10 PDT 2025


================
@@ -2436,13 +2438,20 @@ void VPlanTransforms::handleUncountableEarlyExit(
       ExitIRI->extractLastLaneOfOperand(MiddleBuilder);
     }
     // Add the incoming value from the early exit.
-    if (!IncomingFromEarlyExit->isLiveIn() && !Plan.hasScalarVFOnly()) {
-      VPValue *FirstActiveLane = EarlyExitB.createNaryOp(
-          VPInstruction::FirstActiveLane, {EarlyExitTakenCond}, nullptr,
-          "first.active.lane");
-      IncomingFromEarlyExit = EarlyExitB.createNaryOp(
-          Instruction::ExtractElement, {IncomingFromEarlyExit, FirstActiveLane},
-          nullptr, "early.exit.value");
+    if (!IncomingFromEarlyExit->isLiveIn()) {
+      // Limit range to scalar VF only, if the range contains the scalar VF.
+      bool IsVectorVF = LoopVectorizationPlanner::getDecisionAndClampRange(
+          [](ElementCount VF) { return VF.isVector(); }, Range);
+
+      if (IsVectorVF) {
----------------
ElvisWang123 wrote:

Done, thanks!

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


More information about the llvm-commits mailing list