[llvm] [VPlan] Add initial CFG simplification, removing BranchOnCond true. (PR #106748)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 13 14:58:36 PDT 2025


================
@@ -7558,10 +7559,11 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
   // Set PlanForEarlyExitLoop to true if the BestPlan has been built from a
   // loop with an uncountable early exit. The legacy cost model doesn't
   // properly model costs for such loops.
+  auto ExitBlocks = BestPlan.getExitBlocks();
   bool PlanForEarlyExitLoop =
-      BestPlan.getVectorLoopRegion() &&
-      BestPlan.getVectorLoopRegion()->getSingleSuccessor() !=
-          BestPlan.getMiddleBlock();
+      std::distance(ExitBlocks.begin(), ExitBlocks.end()) > 2 ||
+      (std::distance(ExitBlocks.begin(), ExitBlocks.end()) == 1 &&
+       (*ExitBlocks.begin())->getNumPredecessors() > 1);
----------------
fhahn wrote:

The whole block is wrapped under `ifndef NDEBUG`.

The single exit block with multiple predecessor is generated when  early exiting and latch exit go to the same exit block.



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


More information about the llvm-commits mailing list