[llvm] [VPlan] Introduce ComputeReductionResult VPInstruction opcode. (PR #70253)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 09:24:00 PST 2024


================
@@ -7664,6 +7531,17 @@ SCEV2ValueTy LoopVectorizationPlanner::executePlan(
 
   BestVPlan.execute(&State);
 
+  // 2.5 Collect reduction resume values.
+  DenseMap<const RecurrenceDescriptor *, Value *> ReductionResumeValues;
+  auto *ExitBlock =
+      cast<VPBasicBlock>(BestVPlan.getVectorLoopRegion()->getSingleSuccessor());
+  for (VPRecipeBase &R : *ExitBlock) {
+    collectMergePhiForReduction(dyn_cast<VPInstruction>(&R),
+                                ReductionResumeValues, State, OrigLoop,
+                                State.CFG.VPBB2IRBB[ExitBlock]);
----------------
ayalz wrote:

```suggestion
  auto *ExitVPBB =
      cast<VPBasicBlock>(BestVPlan.getVectorLoopRegion()->getSingleSuccessor());
  for (VPRecipeBase &R : *ExitVPBB) {
    collectMergePhiForReduction(dyn_cast<VPInstruction>(&R),
                                ReductionResumeValues, State, OrigLoop,
                                State.CFG.VPBB2IRBB[ExitVPBB]);
```
for consistency with HeaderVPBB below.

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


More information about the llvm-commits mailing list