[llvm] 8299bfa - [VPlan] Extract reduction result insertion point to variable (NFCI).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 08:26:10 PDT 2024


Author: Florian Hahn
Date: 2024-07-04T16:25:49+01:00
New Revision: 8299bfaf299527c63f61f1bf9abffb88fad3eb38

URL: https://github.com/llvm/llvm-project/commit/8299bfaf299527c63f61f1bf9abffb88fad3eb38
DIFF: https://github.com/llvm/llvm-project/commit/8299bfaf299527c63f61f1bf9abffb88fad3eb38.diff

LOG: [VPlan] Extract reduction result insertion point to variable (NFCI).

Split off from https://github.com/llvm/llvm-project/pull/92651 as
suggested.

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 d7b0240fd8a81..2c69566d45375 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9011,6 +9011,9 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
     }
   }
   Builder.setInsertPoint(&*LatchVPBB->begin());
+  VPBasicBlock *MiddleVPBB =
+      cast<VPBasicBlock>(VectorLoopRegion->getSingleSuccessor());
+  VPBasicBlock::iterator IP = MiddleVPBB->getFirstNonPhi();
   for (VPRecipeBase &R :
        Plan->getVectorLoopRegion()->getEntryBasicBlock()->phis()) {
     VPReductionPHIRecipe *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
@@ -9119,8 +9122,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
     // also modeled in VPlan.
     auto *FinalReductionResult = new VPInstruction(
         VPInstruction::ComputeReductionResult, {PhiR, NewExitingVPV}, ExitDL);
-    cast<VPBasicBlock>(VectorLoopRegion->getSingleSuccessor())
-        ->appendRecipe(FinalReductionResult);
+    FinalReductionResult->insertBefore(*MiddleVPBB, IP);
     OrigExitingVPV->replaceUsesWithIf(
         FinalReductionResult,
         [](VPUser &User, unsigned) { return isa<VPLiveOut>(&User); });


        


More information about the llvm-commits mailing list