@@ -128,32 +128,6 @@ inline bind_ty<VPValue> m_VPValue(VPValue *&V) { return V; }
128
128
129
129
namespace detail {
130
130
131
- // / A helper to match an opcode against multiple recipe types.
132
- template <unsigned Opcode, typename ...> struct MatchRecipeAndOpcode {};
133
-
134
- template <unsigned Opcode, typename RecipeTy>
135
- struct MatchRecipeAndOpcode <Opcode, RecipeTy> {
136
- static bool match (const VPRecipeBase *R) {
137
- auto *DefR = dyn_cast<RecipeTy>(R);
138
- // Check for recipes that do not have opcodes.
139
- if constexpr (std::is_same<RecipeTy, VPScalarIVStepsRecipe>::value ||
140
- std::is_same<RecipeTy, VPCanonicalIVPHIRecipe>::value ||
141
- std::is_same<RecipeTy, VPWidenSelectRecipe>::value ||
142
- std::is_same<RecipeTy, VPDerivedIVRecipe>::value ||
143
- std::is_same<RecipeTy, VPWidenGEPRecipe>::value)
144
- return DefR;
145
- else
146
- return DefR && DefR->getOpcode () == Opcode;
147
- }
148
- };
149
-
150
- template <unsigned Opcode, typename RecipeTy, typename ... RecipeTys>
151
- struct MatchRecipeAndOpcode <Opcode, RecipeTy, RecipeTys...> {
152
- static bool match (const VPRecipeBase *R) {
153
- return MatchRecipeAndOpcode<Opcode, RecipeTy>::match (R) ||
154
- MatchRecipeAndOpcode<Opcode, RecipeTys...>::match (R);
155
- }
156
- };
157
131
template <typename TupleTy, typename Fn, std::size_t ... Is>
158
132
bool CheckTupleElements (const TupleTy &Ops, Fn P, std::index_sequence<Is...>) {
159
133
return (P (std::get<Is>(Ops), Is) && ...);
@@ -193,8 +167,9 @@ struct Recipe_match {
193
167
}
194
168
195
169
bool match (const VPRecipeBase *R) const {
196
- if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>:: match (R ))
170
+ if ((!matchRecipeAndOpcode< RecipeTys>(R) && ... ))
197
171
return false ;
172
+
198
173
assert (R->getNumOperands () == std::tuple_size<Ops_t>::value &&
199
174
" recipe with matched opcode the expected number of operands" );
200
175
@@ -208,6 +183,21 @@ struct Recipe_match {
208
183
return Op.match (R->getOperand (R->getNumOperands () - Idx - 1 ));
209
184
});
210
185
}
186
+
187
+ private:
188
+ template <typename RecipeTy>
189
+ static bool matchRecipeAndOpcode (const VPRecipeBase *R) {
190
+ auto *DefR = dyn_cast<RecipeTy>(R);
191
+ // Check for recipes that do not have opcodes.
192
+ if constexpr (std::is_same<RecipeTy, VPScalarIVStepsRecipe>::value ||
193
+ std::is_same<RecipeTy, VPCanonicalIVPHIRecipe>::value ||
194
+ std::is_same<RecipeTy, VPWidenSelectRecipe>::value ||
195
+ std::is_same<RecipeTy, VPDerivedIVRecipe>::value ||
196
+ std::is_same<RecipeTy, VPWidenGEPRecipe>::value)
197
+ return DefR;
198
+ else
199
+ return DefR && DefR->getOpcode () == Opcode;
200
+ }
211
201
};
212
202
213
203
template <typename Op0_t, unsigned Opcode, typename ... RecipeTys>
0 commit comments