[llvm] [LV] Support conditional scalar assignments of masked operations (PR #178862)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 03:14:43 PST 2026


================
@@ -473,9 +499,17 @@ bool RecurrenceDescriptor::AddReductionVar(
         !isAnyOfRecurrenceKind(Kind) && hasMultipleUsesOf(Cur, VisitedInsts, 1))
       return false;
 
-    // All inputs to a PHI node must be a reduction value.
-    if (IsAPhi && Cur != Phi && !areAllUsesIn(Cur, VisitedInsts))
-      return false;
+    if (IsAPhi && Cur != Phi) {
+      if (!areAllUsesIn(Cur, VisitedInsts)) {
+        // A "FindLast-like" Phi acts like a conditional select between the
+        // previous reduction value, and an arbitrary value.
+        FoundFindLastLikePhi =
+            Kind == RecurKind::FindLast && !FoundFindLastLikePhi &&
----------------
sdesmalen-arm wrote:

I'm a bit puzzled by the `&& !FoundFindLastLikePhi` (there's no test for this case either).
If it had already found a FindLastLikePhi, should it return false here? Or can this never happen?

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


More information about the llvm-commits mailing list