[llvm] [VPlan] Introduce ComputeReductionResult VPInstruction opcode. (PR #70253)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 26 05:59:59 PDT 2023
================
@@ -7719,6 +7542,27 @@ SCEV2ValueTy LoopVectorizationPlanner::executePlan(
BestVPlan.execute(&State);
+ DenseMap<const RecurrenceDescriptor *, Value *> ReductionResumeValues;
+ for (VPRecipeBase &R : *cast<VPBasicBlock>(
+ BestVPlan.getVectorLoopRegion()->getSingleSuccessor())) {
+
+ auto *Red = dyn_cast<VPInstruction>(&R);
+ if (!Red || Red->getOpcode() != VPInstruction::ComputeReductionResult)
+ continue;
+
+ Value *FinalValue = State.get(
+ Red, VPIteration(State.UF - 1, VPLane::getLastLaneForVF(State.VF)));
+ auto *PhiR = cast<VPReductionPHIRecipe>(Red->getOperand(0));
+ assert(FinalValue->hasOneUse() || PhiR->isInLoop() ||
+ PhiR->getRecurrenceDescriptor().IntermediateStore);
+
+ PHINode *MergePhi = nullptr;
+ for (Value *U : FinalValue->users())
+ if (auto *P = dyn_cast<PHINode>(U))
+ MergePhi = P;
----------------
alexey-bataev wrote:
break; ? to early exit out of the loop if the first phi is found?
https://github.com/llvm/llvm-project/pull/70253
More information about the llvm-commits
mailing list