[llvm] [IVDescriptors] Reject FindLast candidates with loop invariant conditions (PR #184340)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 05:51:26 PST 2026
================
@@ -924,11 +924,15 @@ RecurrenceDescriptor::isFindPattern(Loop *TheLoop, PHINode *OrigPhi,
// select(cmp(), phi, value) or
// select(cmp(), value, phi)
// TODO: Match selects with multi-use cmp conditions.
- Value *NonRdxPhi = nullptr;
- if (!match(I, m_CombineOr(m_Select(m_OneUse(m_Cmp()), m_Value(NonRdxPhi),
+ Value *Cmp = nullptr;
+ if (!match(I, m_CombineOr(m_Select(m_OneUse(m_Value(Cmp, m_Cmp())), m_Value(),
m_Specific(OrigPhi)),
- m_Select(m_OneUse(m_Cmp()), m_Specific(OrigPhi),
- m_Value(NonRdxPhi)))))
+ m_Select(m_OneUse(m_Value(Cmp, m_Cmp())),
+ m_Specific(OrigPhi), m_Value()))))
+ return InstDesc(false, I);
+
+ // If the condition is loop invariant, bail out.
+ if (TheLoop->isLoopInvariant(Cmp))
----------------
fhahn wrote:
why does it matter if the condition is loop invariant or not?
https://github.com/llvm/llvm-project/pull/184340
More information about the llvm-commits
mailing list