Skip to content

Commit aee016b

Browse files
committed
[VPlan] Add matchers for remaining FP min/max intrinsics (NFC).
Add dedicated matchers for minimum,maximum,minimumnum and maximumnum intrinsics, similar for the existing matchers for maxnum and minnum. As suggested in #137335.
1 parent efd46bc commit aee016b

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

llvm/include/llvm/IR/PatternMatch.h

+24
Original file line numberDiff line numberDiff line change
@@ -2747,12 +2747,36 @@ inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty m_FMin(const Opnd0 &Op0,
27472747
return m_Intrinsic<Intrinsic::minnum>(Op0, Op1);
27482748
}
27492749

2750+
template <typename Opnd0, typename Opnd1>
2751+
inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty m_FMinimum(const Opnd0 &Op0,
2752+
const Opnd1 &Op1) {
2753+
return m_Intrinsic<Intrinsic::minimum>(Op0, Op1);
2754+
}
2755+
2756+
template <typename Opnd0, typename Opnd1>
2757+
inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty
2758+
m_FMinimumNum(const Opnd0 &Op0, const Opnd1 &Op1) {
2759+
return m_Intrinsic<Intrinsic::minimumnum>(Op0, Op1);
2760+
}
2761+
27502762
template <typename Opnd0, typename Opnd1>
27512763
inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty m_FMax(const Opnd0 &Op0,
27522764
const Opnd1 &Op1) {
27532765
return m_Intrinsic<Intrinsic::maxnum>(Op0, Op1);
27542766
}
27552767

2768+
template <typename Opnd0, typename Opnd1>
2769+
inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty m_FMaximum(const Opnd0 &Op0,
2770+
const Opnd1 &Op1) {
2771+
return m_Intrinsic<Intrinsic::maximum>(Op0, Op1);
2772+
}
2773+
2774+
template <typename Opnd0, typename Opnd1>
2775+
inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty
2776+
m_FMaximumNum(const Opnd0 &Op0, const Opnd1 &Op1) {
2777+
return m_Intrinsic<Intrinsic::maximumnum>(Op0, Op1);
2778+
}
2779+
27562780
template <typename Opnd0, typename Opnd1, typename Opnd2>
27572781
inline typename m_Intrinsic_Ty<Opnd0, Opnd1, Opnd2>::Ty
27582782
m_FShl(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2) {

llvm/lib/Analysis/IVDescriptors.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -784,17 +784,17 @@ RecurrenceDescriptor::isMinMaxPattern(Instruction *I, RecurKind Kind,
784784
return InstDesc(Kind == RecurKind::FMin, I);
785785
if (match(I, m_OrdOrUnordFMax(m_Value(), m_Value())))
786786
return InstDesc(Kind == RecurKind::FMax, I);
787-
if (match(I, m_Intrinsic<Intrinsic::minnum>(m_Value(), m_Value())))
787+
if (match(I, m_FMin(m_Value(), m_Value())))
788788
return InstDesc(Kind == RecurKind::FMin, I);
789-
if (match(I, m_Intrinsic<Intrinsic::maxnum>(m_Value(), m_Value())))
789+
if (match(I, m_FMax(m_Value(), m_Value())))
790790
return InstDesc(Kind == RecurKind::FMax, I);
791-
if (match(I, m_Intrinsic<Intrinsic::minimumnum>(m_Value(), m_Value())))
791+
if (match(I, m_FMinimumNum(m_Value(), m_Value())))
792792
return InstDesc(Kind == RecurKind::FMinimumNum, I);
793-
if (match(I, m_Intrinsic<Intrinsic::maximumnum>(m_Value(), m_Value())))
793+
if (match(I, m_FMaximumNum(m_Value(), m_Value())))
794794
return InstDesc(Kind == RecurKind::FMaximumNum, I);
795-
if (match(I, m_Intrinsic<Intrinsic::minimum>(m_Value(), m_Value())))
795+
if (match(I, m_FMinimum(m_Value(), m_Value())))
796796
return InstDesc(Kind == RecurKind::FMinimum, I);
797-
if (match(I, m_Intrinsic<Intrinsic::maximum>(m_Value(), m_Value())))
797+
if (match(I, m_FMaximum(m_Value(), m_Value())))
798798
return InstDesc(Kind == RecurKind::FMaximum, I);
799799

800800
return InstDesc(false, I);

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -21851,9 +21851,9 @@ class HorizontalReduction {
2185121851
if (match(I, m_Intrinsic<Intrinsic::minnum>(m_Value(), m_Value())))
2185221852
return RecurKind::FMin;
2185321853

21854-
if (match(I, m_Intrinsic<Intrinsic::maximum>(m_Value(), m_Value())))
21854+
if (match(I, m_FMaximum(m_Value(), m_Value())))
2185521855
return RecurKind::FMaximum;
21856-
if (match(I, m_Intrinsic<Intrinsic::minimum>(m_Value(), m_Value())))
21856+
if (match(I, m_FMinimum(m_Value(), m_Value())))
2185721857
return RecurKind::FMinimum;
2185821858
// This matches either cmp+select or intrinsics. SLP is expected to handle
2185921859
// either form.
@@ -23501,13 +23501,13 @@ static Instruction *getReductionInstr(const DominatorTree *DT, PHINode *P,
2350123501
static bool matchRdxBop(Instruction *I, Value *&V0, Value *&V1) {
2350223502
if (match(I, m_BinOp(m_Value(V0), m_Value(V1))))
2350323503
return true;
23504-
if (match(I, m_Intrinsic<Intrinsic::maxnum>(m_Value(V0), m_Value(V1))))
23504+
if (match(I, m_FMax(m_Value(V0), m_Value(V1))))
2350523505
return true;
23506-
if (match(I, m_Intrinsic<Intrinsic::minnum>(m_Value(V0), m_Value(V1))))
23506+
if (match(I, m_FMin(m_Value(V0), m_Value(V1))))
2350723507
return true;
23508-
if (match(I, m_Intrinsic<Intrinsic::maximum>(m_Value(V0), m_Value(V1))))
23508+
if (match(I, m_FMaximum(m_Value(V0), m_Value(V1))))
2350923509
return true;
23510-
if (match(I, m_Intrinsic<Intrinsic::minimum>(m_Value(V0), m_Value(V1))))
23510+
if (match(I, m_FMinimum(m_Value(V0), m_Value(V1))))
2351123511
return true;
2351223512
if (match(I, m_Intrinsic<Intrinsic::smax>(m_Value(V0), m_Value(V1))))
2351323513
return true;

0 commit comments

Comments
 (0)