Skip to content

Commit 785e824

Browse files
author
git apple-llvm automerger
committed
Merge commit '049aa179dc37' from llvm.org/main into next
2 parents 8b3635f + 049aa17 commit 785e824

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,6 @@ inline match_combine_or<LTy, RTy> m_CombineOr(const LTy &L, const RTy &R) {
126126
/// Match a VPValue, capturing it if we match.
127127
inline bind_ty<VPValue> m_VPValue(VPValue *&V) { return V; }
128128

129-
namespace detail {
130-
131-
template <typename TupleTy, typename Fn, std::size_t... Is>
132-
bool CheckTupleElements(const TupleTy &Ops, Fn P, std::index_sequence<Is...>) {
133-
return (P(std::get<Is>(Ops), Is) && ...);
134-
}
135-
136-
/// Helper to check if predicate \p P holds on all tuple elements in \p Ops
137-
template <typename TupleTy, typename Fn>
138-
bool all_of_tuple_elements(const TupleTy &Ops, Fn P) {
139-
return CheckTupleElements(
140-
Ops, P, std::make_index_sequence<std::tuple_size<TupleTy>::value>{});
141-
}
142-
} // namespace detail
143-
144129
template <typename Ops_t, unsigned Opcode, bool Commutative,
145130
typename... RecipeTys>
146131
struct Recipe_match {
@@ -173,13 +158,14 @@ struct Recipe_match {
173158
assert(R->getNumOperands() == std::tuple_size<Ops_t>::value &&
174159
"recipe with matched opcode the expected number of operands");
175160

176-
if (detail::all_of_tuple_elements(Ops, [R](auto Op, unsigned Idx) {
161+
auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
162+
if (all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
177163
return Op.match(R->getOperand(Idx));
178164
}))
179165
return true;
180166

181167
return Commutative &&
182-
detail::all_of_tuple_elements(Ops, [R](auto Op, unsigned Idx) {
168+
all_of_tuple_elements(IdxSeq, [R](auto Op, unsigned Idx) {
183169
return Op.match(R->getOperand(R->getNumOperands() - Idx - 1));
184170
});
185171
}
@@ -198,6 +184,13 @@ struct Recipe_match {
198184
else
199185
return DefR && DefR->getOpcode() == Opcode;
200186
}
187+
188+
/// Helper to check if predicate \p P holds on all tuple elements in Ops using
189+
/// the provided index sequence.
190+
template <typename Fn, std::size_t... Is>
191+
bool all_of_tuple_elements(std::index_sequence<Is...>, Fn P) const {
192+
return (P(std::get<Is>(Ops), Is) && ...);
193+
}
201194
};
202195

203196
template <typename Op0_t, unsigned Opcode, typename... RecipeTys>

0 commit comments

Comments
 (0)