[llvm] [VPlan] Introduce ComputeReductionResult VPInstruction opcode. (PR #70253)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 08:36:52 PST 2023
================
@@ -7640,6 +7463,42 @@ SCEV2ValueTy LoopVectorizationPlanner::executePlan(
BestVPlan.execute(&State);
+ DenseMap<const RecurrenceDescriptor *, Value *> ReductionResumeValues;
+ BasicBlock *OrigScalarPH = OrigLoop->getLoopPreheader();
+ // Check if ResResult is a CompueReductionResult instruction, and if it is
+ // return the merge phi node for it.
+ auto GetMergePhiForReduction = [&State,
+ OrigScalarPH](VPInstruction *RedResult)
+ -> std::pair<const RecurrenceDescriptor *, PHINode *> {
+ if (!RedResult ||
+ RedResult->getOpcode() != VPInstruction::ComputeReductionResult)
+ return {nullptr, nullptr};
+
+ Value *FinalValue =
+ State.get(RedResult, VPIteration(State.UF - 1,
+ VPLane::getLastLaneForVF(State.VF)));
+ auto *PhiR = cast<VPReductionPHIRecipe>(RedResult->getOperand(0));
+ assert(FinalValue->hasOneUse() || PhiR->isInLoop() ||
+ PhiR->getRecurrenceDescriptor().IntermediateStore &&
----------------
ayalz wrote:
Would it be better for a ComputeReductionResult recipe to hold the recurrence descriptor and inLoop indicator, rather than search for them during execution?
Worth clarifying why inLoop needs ComputeReductionResult, outside loop.
https://github.com/llvm/llvm-project/pull/70253
More information about the llvm-commits
mailing list