[llvm] [VPlan] Use parameter packs to avoid unary/binary/ternary matchers. NFC (PR #152272)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 04:08:10 PDT 2025
================
@@ -449,72 +375,66 @@ m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
/// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative
/// version of the matcher.
template <typename Op0_t, typename Op1_t, bool Commutative = false>
-inline AllBinaryRecipe_match<Op0_t, Op1_t, Instruction::Or, Commutative>
+inline AllRecipe_match<Instruction::Or, Commutative, Op0_t, Op1_t>
m_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
return m_Binary<Instruction::Or, Op0_t, Op1_t, Commutative>(Op0, Op1);
}
template <typename Op0_t, typename Op1_t>
-inline AllBinaryRecipe_match<Op0_t, Op1_t, Instruction::Or,
- /*Commutative*/ true>
+inline AllRecipe_match<Instruction::Or, /*Commutative*/ true, Op0_t, Op1_t>
m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
return m_BinaryOr<Op0_t, Op1_t, /*Commutative*/ true>(Op0, Op1);
}
template <typename Op0_t, typename Op1_t>
using GEPLikeRecipe_match =
- BinaryRecipe_match<Op0_t, Op1_t, Instruction::GetElementPtr, false,
- VPWidenRecipe, VPReplicateRecipe, VPWidenGEPRecipe,
- VPInstruction>;
+ Recipe_match<std::tuple<Op0_t, Op1_t>, Instruction::GetElementPtr, false,
+ VPWidenRecipe, VPReplicateRecipe, VPWidenGEPRecipe,
+ VPInstruction>;
template <typename Op0_t, typename Op1_t>
inline GEPLikeRecipe_match<Op0_t, Op1_t> m_GetElementPtr(const Op0_t &Op0,
const Op1_t &Op1) {
return GEPLikeRecipe_match<Op0_t, Op1_t>(Op0, Op1);
}
-template <typename Op0_t, typename Op1_t, typename Op2_t, unsigned Opcode>
-using AllTernaryRecipe_match =
- Recipe_match<std::tuple<Op0_t, Op1_t, Op2_t>, Opcode, false,
- VPReplicateRecipe, VPInstruction, VPWidenSelectRecipe>;
-
template <typename Op0_t, typename Op1_t, typename Op2_t>
-inline AllTernaryRecipe_match<Op0_t, Op1_t, Op2_t, Instruction::Select>
+inline AllRecipe_match<Instruction::Select, false, Op0_t, Op1_t, Op2_t>
m_Select(const Op0_t &Op0, const Op1_t &Op1, const Op2_t &Op2) {
- return AllTernaryRecipe_match<Op0_t, Op1_t, Op2_t, Instruction::Select>(
+ return AllRecipe_match<Instruction::Select, false, Op0_t, Op1_t, Op2_t>(
{Op0, Op1, Op2});
}
template <typename Op0_t>
-inline match_combine_or<UnaryVPInstruction_match<Op0_t, VPInstruction::Not>,
- AllBinaryRecipe_match<int_pred_ty<is_all_ones>, Op0_t,
- Instruction::Xor, true>>
+inline match_combine_or<
+ VPInstruction_match<VPInstruction::Not, Op0_t>,
+ AllRecipe_match<Instruction::Xor, true, int_pred_ty<is_all_ones>, Op0_t>>
m_Not(const Op0_t &Op0) {
return m_CombineOr(m_VPInstruction<VPInstruction::Not>(Op0),
m_c_Binary<Instruction::Xor>(m_AllOnes(), Op0));
}
template <typename Op0_t, typename Op1_t>
inline match_combine_or<
- BinaryVPInstruction_match<Op0_t, Op1_t, VPInstruction::LogicalAnd>,
- AllTernaryRecipe_match<Op0_t, Op1_t, specific_intval<1>,
- Instruction::Select>>
+ VPInstruction_match<VPInstruction::LogicalAnd, Op0_t, Op1_t>,
+ AllRecipe_match<Instruction::Select, false, Op0_t, Op1_t,
----------------
artagnon wrote:
```suggestion
AllRecipe_match<Instruction::Select, /* Commutative = */ false, Op0_t, Op1_t,
```
https://github.com/llvm/llvm-project/pull/152272
More information about the llvm-commits
mailing list