[llvm] [LV] Vectorize conditional scalar assignments (PR #158088)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 22 08:55:56 PDT 2025
================
@@ -712,6 +714,27 @@ RecurrenceDescriptor::isFindIVPattern(RecurKind Kind, Loop *TheLoop,
m_Value(NonRdxPhi)))))
return InstDesc(false, I);
+ if (isFindLastRecurrenceKind(Kind)) {
+ // Must be an integer scalar.
+ Type *Type = OrigPhi->getType();
+ if (!Type->isIntegerTy() && !Type->isPointerTy())
+ return InstDesc(false, I);
+
+ // FIXME: Support more complex patterns, including multiple selects.
+ // Phi or Select must be used only outside the loop,
+ // except for each other.
+ if (!all_of(I->users(), [OrigPhi, TheLoop](User *U) {
+ if (U == OrigPhi)
+ return true;
+ if (auto *UI = dyn_cast<Instruction>(U))
+ return !TheLoop->contains(UI);
+ return false;
+ }))
+ return InstDesc(false, I);
----------------
MacDue wrote:
nit: I think this can be simplified to:
```suggestion
for (User* U : I->users()) {
if (U == OrigPhi)
continue;
if (auto *UI = dyn_cast<Instruction>(U); UI && !TheLoop->contains(UI))
continue;
return InstDesc(false, I);
}
```
https://github.com/llvm/llvm-project/pull/158088
More information about the llvm-commits
mailing list