[llvm] [VPlan] Simplify branch on False in VPlan transform (NFC). (PR #140409)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 10:45:24 PDT 2025


================
@@ -541,37 +545,31 @@ void VPlanTransforms::prepareForVectorization(
   //    Thus if tail is to be folded, we know we don't need to run the
   //    remainder and we can set the condition to true.
   // 3) Otherwise, construct a runtime check.
+  VPBlockUtils::connectBlocks(MiddleVPBB, ScalarPH);
+  // Also connect the entry block to the scalar preheader.
+  VPBlockUtils::connectBlocks(Plan.getEntry(), ScalarPH);
+  Plan.getEntry()->swapSuccessors();
 
-  if (!RequiresScalarEpilogueCheck) {
-    if (auto *LatchExitVPB = MiddleVPBB->getSingleSuccessor())
-      VPBlockUtils::disconnectBlocks(MiddleVPBB, LatchExitVPB);
-    VPBlockUtils::connectBlocks(MiddleVPBB, ScalarPH);
-    // The exit blocks are unreachable, remove their recipes to make sure no
-    // users remain that may pessimize transforms.
-    for (auto *EB : Plan.getExitBlocks()) {
-      for (VPRecipeBase &R : make_early_inc_range(*EB))
-        R.eraseFromParent();
-    }
+  if (MiddleVPBB->getNumSuccessors() != 2)
----------------
fhahn wrote:

Thanks, moved the comment with cases down and documented the case here.

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


More information about the llvm-commits mailing list