[llvm] 7500cea - [VPlan] Flatten the CFG separately after creating wide recipes (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun May 11 13:30:26 PDT 2025


Author: Florian Hahn
Date: 2025-05-11T21:30:01+01:00
New Revision: 7500cead4e000d82d62f99f2896ffa94ee08ff7e

URL: https://github.com/llvm/llvm-project/commit/7500cead4e000d82d62f99f2896ffa94ee08ff7e
DIFF: https://github.com/llvm/llvm-project/commit/7500cead4e000d82d62f99f2896ffa94ee08ff7e.diff

LOG: [VPlan] Flatten the CFG separately after creating wide recipes (NFC).

Move flattening of the CFG out of the loop that creates the wide
recipes. This simplifies the already large loop and prepares for moving
flattening to a separate transform.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c9a872dcd03bb..2393ac7182dfd 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9464,7 +9464,6 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range,
       HeaderVPBB);
 
   VPBasicBlock::iterator MBIP = MiddleVPBB->getFirstNonPhi();
-  VPBlockBase *PrevVPBB = nullptr;
   for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
     // Create mask based on the IR BB corresponding to VPBB.
     // TODO: Predicate directly based on VPlan.
@@ -9548,7 +9547,10 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range,
                "Unexpected multidef recipe");
       R.eraseFromParent();
     }
+  }
 
+  VPBlockBase *PrevVPBB = nullptr;
+  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
     // Flatten the CFG in the loop. Masks for blocks have already been generated
     // and added to recipes as needed. To do so, first disconnect VPBB from its
     // successors. Then connect VPBB to the previously visited VPBB.


        


More information about the llvm-commits mailing list