================
@@ -4442,6 +4495,29 @@ void VPReductionPHIRecipe::print(raw_ostream &O, const 
Twine &Indent,
 }
 #endif
 
+void VPMonotonicPHIRecipe::execute(VPTransformState &State) {
+  assert(getParent()->getPlan()->getUF() == 1 && "Expected unroll factor 1.");
+  Value *Start = getStartValue()->getLiveInIRValue();
+  BasicBlock *VectorPH =
+      State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
+  PHINode *MonotonicPHI =
+      State.Builder.CreatePHI(Start->getType(), 2, "monotonic.iv");
+  MonotonicPHI->addIncoming(Start, VectorPH);
+  MonotonicPHI->setDebugLoc(getDebugLoc());
+  State.set(this, MonotonicPHI, /*IsScalar=*/true);
+}
----------------
skachkov-sc wrote:

The only rational for new recipe was to simplify "adjusting" of VPlan: we need 
to insert VPInstruction::ComputeMonotonicRecipe at the backedge of such phi 
(that will incement phi value on ctpop(mask)). This looks similar to handling 
of reductions: VPMonotonicPHIRecipe/VPInstruction::ComputeMonotonicResult is 
symmetric to VPReductionPHIRecipe/VPInstruction::ComputeReductionResult. 
Probably VPWidenPHI recipe can be used there, but there are some places in code 
when we want to distinguish "monotonic" header phis ftom the others.

https://github.com/llvm/llvm-project/pull/140723
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to