[llvm] [VPlan] Use ResumePhi to create reduction resume phis. (PR #110004)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 27 06:30:16 PDT 2024


================
@@ -9511,6 +9497,22 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
         });
     FinalReductionResult->insertBefore(*MiddleVPBB, IP);
 
+    VPBasicBlock *ScalarPHVPBB = nullptr;
+    if (MiddleVPBB->getNumSuccessors() == 2) {
+      // Order is strict: first is the exit block, second is the scalar
----------------
ayalz wrote:

Can simplify by retrieving the last successor, `MiddleVPBB->getSuccessors()[MiddleVPBB->getNumSuccessors()-1]`.

In general, only Exit should be a VPIRBB, and/or should be recorded in VPlan, so can identify the ScalarPHVPBB as the first successor of middle-block that is not Exit.

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


More information about the llvm-commits mailing list