[llvm] [VPlan] Use ResumePhi to create reduction resume phis. (PR #110004)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 25 03:07:46 PDT 2024
================
@@ -7494,67 +7494,49 @@ static void addRuntimeUnrollDisableMetaData(Loop *L) {
}
}
-// Check if \p RedResult is a ComputeReductionResult instruction, and if it is
-// create a merge phi node for it.
-static void createAndCollectMergePhiForReduction(
- VPInstruction *RedResult,
- VPTransformState &State, Loop *OrigLoop, BasicBlock *LoopMiddleBlock,
- bool VectorizingEpilogue) {
+// If \p RedResult is a ComputeReductionResult when vectorizing the epilog loop,
+// update the reduction's scalar PHI node by adding the incoming value from the
+// main vector loop.
+static void updateMergePhiForReductionForEpilogueVectorization(
+ VPInstruction *RedResult, VPTransformState &State, Loop *OrigLoop,
+ BasicBlock *LoopMiddleBlock) {
if (!RedResult ||
RedResult->getOpcode() != VPInstruction::ComputeReductionResult)
return;
+ using namespace VPlanPatternMatch;
+ VPValue *ResumePhiVPV =
+ cast<VPInstruction>(*find_if(RedResult->users(), [](VPUser *U) {
+ return match(U, m_VPInstruction<VPInstruction::ResumePhi>(m_VPValue(),
+ m_VPValue()));
+ }));
+ assert(ResumePhiVPV->getNumUsers() == 1 &&
+ "ResumePhi must have a single user");
----------------
ayalz wrote:
I meant to assert that RedResult has exactly one user that is a ResumePhi (say using count_if), as we only deal with the first one. Overall one ResumePhi user is expected in scalar preheader and another VPIRInstruction user in exit block?
https://github.com/llvm/llvm-project/pull/110004
More information about the llvm-commits
mailing list