@@ -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.
127127inline 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-
144129template <typename Ops_t, unsigned Opcode, bool Commutative,
145130 typename ... RecipeTys>
146131struct 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
203196template <typename Op0_t, unsigned Opcode, typename ... RecipeTys>
0 commit comments