[llvm] VPlan/PatternMatch: introduce m_c_Mul (PR #93950)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 02:04:11 PDT 2024


================
@@ -268,10 +268,16 @@ m_Binary(const Op0_t &Op0, const Op1_t &Op1) {
   return AllBinaryRecipe_match<Op0_t, Op1_t, Opcode, Commutative>(Op0, Op1);
 }
 
-template <typename Op0_t, typename Op1_t>
-inline AllBinaryRecipe_match<Op0_t, Op1_t, Instruction::Mul>
+template <typename Op0_t, typename Op1_t, bool Commutative = false>
+inline AllBinaryRecipe_match<Op0_t, Op1_t, Instruction::Mul, Commutative>
 m_Mul(const Op0_t &Op0, const Op1_t &Op1) {
-  return m_Binary<Instruction::Mul, Op0_t, Op1_t>(Op0, Op1);
+  return m_Binary<Instruction::Mul, Op0_t, Op1_t, Commutative>(Op0, Op1);
+}
+
+template <typename Op0_t, typename Op1_t, bool Commutative = true>
+inline AllBinaryRecipe_match<Op0_t, Op1_t, Instruction::Mul, Commutative>
+m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
----------------
fhahn wrote:

What's the motivation  allowing to override `Commutative` for this matcher? `m_c_XXX` should always match commutatively. The reason for `m_XXX` taking `Commutative` as argument is so it can be used for `m_c_XXX` implementations

https://github.com/llvm/llvm-project/pull/93950


More information about the llvm-commits mailing list