From 0e743ecca018e9fa7482dc8bec62eae8cd0c929b Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Wed, 5 Jun 2024 23:02:57 +0100 Subject: [PATCH] VPlan/PatternMatch: introduce m_c_Mul (NFC) (#93950) Introduce a commutative version of m_Mul, and simplify a usage based on it. --- llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h | 7 +++++++ llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h index 058746880743..d6b4acb2bdba 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h +++ b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h @@ -274,6 +274,13 @@ m_Mul(const Op0_t &Op0, const Op1_t &Op1) { return m_Binary(Op0, Op1); } +template +inline AllBinaryRecipe_match +m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) { + return m_Binary(Op0, Op1); +} + /// Match a binary OR operation. Note that while conceptually the operands can /// be matched commutatively, \p Commutative defaults to false in line with the /// IR-based pattern matching infrastructure. Use m_c_BinaryOr for a commutative diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index ab3b5cf2b9da..8ec67eb2f54b 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -1037,8 +1037,7 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) { return; } - if (match(&R, m_CombineOr(m_Mul(m_VPValue(A), m_SpecificInt(1)), - m_Mul(m_SpecificInt(1), m_VPValue(A))))) + if (match(&R, m_c_Mul(m_VPValue(A), m_SpecificInt(1)))) return R.getVPSingleValue()->replaceAllUsesWith(A); }