[llvm] [VPlan] Introduce m_Cmp; match more compares (PR #154771)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 07:23:36 PDT 2025


================
@@ -395,24 +395,30 @@ m_c_BinaryOr(const Op0_t &Op0, const Op1_t &Op1) {
   return m_c_Binary<Instruction::Or, Op0_t, Op1_t>(Op0, Op1);
 }
 
-/// ICmp_match is a variant of BinaryRecipe_match that also binds the comparison
-/// predicate.
-template <typename Op0_t, typename Op1_t> struct ICmp_match {
+/// Cmp_match is a variant of BinaryRecipe_match that also binds the comparison
+/// predicate. Opcodes must be within Instruction::ICmp or Instruction::FCmp.
+template <typename Op0_t, typename Op1_t, unsigned... Opcodes>
+struct Cmp_match {
+  static_assert(sizeof...(Opcodes) == 1 || sizeof...(Opcodes) == 2);
+  static_assert((((Opcodes == Instruction::ICmp) ||
+                  (Opcodes == Instruction::FCmp)) ||
+                 ...));
+
   CmpPredicate *Predicate = nullptr;
   Op0_t Op0;
   Op1_t Op1;
 
-  ICmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
+  Cmp_match(CmpPredicate &Pred, const Op0_t &Op0, const Op1_t &Op1)
       : Predicate(&Pred), Op0(Op0), Op1(Op1) {}
-  ICmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
+  Cmp_match(const Op0_t &Op0, const Op1_t &Op1) : Op0(Op0), Op1(Op1) {}
----------------
artagnon wrote:

Ah yes, there's an || versus && bug in my implementation: will fix :)

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


More information about the llvm-commits mailing list