[llvm] [LV] Allow for vectorizing parallel def-use chains (PR #225405)

Nashe Mncube via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 06:37:27 PDT 2026


================
@@ -354,19 +354,28 @@ static RecurrenceDescriptor getMinMaxRecurrence(PHINode *Phi, Loop *TheLoop,
     return !Chain.contains(U) && TheLoop->contains(U) &&
            GetMinMaxRK(U, A, B) == RecurKind::None;
   });
+
+  // If the backedge value has more than one use we should consider whether
+  // these are actually uses inside the loop.
+  bool BackedgeValueHasOneValidUse =
+      count_if(BackedgeValue->users(), [&](User *U) {
+        return TheLoop->contains(dyn_cast<Instruction>(U));
+      }) == 1;
+
   if (PhiHasInvalidUses) {
     if (!RecurrenceDescriptor::isMinMaxRecurrenceKind(RK) ||
-        !BackedgeValue->hasOneUse())
+        !BackedgeValueHasOneValidUse)
       return {};
     return RecurrenceDescriptor(
         Phi->getIncomingValueForBlock(TheLoop->getLoopPreheader()),
-        /*Exit=*/nullptr, /*Store=*/nullptr, RK, FastMathFlags(),
+        /*Exit=*/nullptr, /*Store=*/nullptr, RK, FMF,
----------------
nasherm wrote:

It is. It looked incorrect but I'll remove it from this patch

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


More information about the llvm-commits mailing list