[llvm] [VPlan] Update final exit value via VPlan. (PR #112147)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 31 03:29:35 PST 2024


================
@@ -8996,17 +8868,86 @@ static SetVector<VPIRInstruction *> collectUsersInExitBlocks(
   return ExitUsersToFix;
 }
 
+/// If \p Incoming is a user of a non-truncated induction, create recipes to
+/// compute the final value and update the user \p ExitIRI.
+static bool addInductionEndValue(
+    VPlan &Plan, VPIRInstruction *ExitIRI, VPValue *Incoming,
+    const MapVector<PHINode *, InductionDescriptor> &Inductions,
+    DenseMap<VPValue *, VPValue *> &EndValues, VPTypeAnalysis &TypeInfo) {
+  if ((isa<VPWidenIntOrFpInductionRecipe>(Incoming) &&
+       !cast<VPWidenIntOrFpInductionRecipe>(Incoming)->getTruncInst()) ||
+      isa<VPWidenPointerInductionRecipe>(Incoming) ||
+      (isa<Instruction>(Incoming->getUnderlyingValue()) &&
+       any_of(cast<Instruction>(Incoming->getUnderlyingValue())->users(),
+              [&Inductions](User *U) {
+                auto *P = dyn_cast<PHINode>(U);
+                return P && Inductions.contains(P);
+              }))) {
+    VPValue *IV;
----------------
ayalz wrote:

```suggestion
    VPValue *IV;
    auto *IncomingR = Incoming->getDefiningRecipe();
    assert(IncomingR && "Unexpected live-in as incoming");
```

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


More information about the llvm-commits mailing list