[llvm] 0e743ec - VPlan/PatternMatch: introduce m_c_Mul (NFC) (#93950)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 15:03:01 PDT 2024
Author: Ramkumar Ramachandra
Date: 2024-06-05T23:02:57+01:00
New Revision: 0e743ecca018e9fa7482dc8bec62eae8cd0c929b
URL: https://github.com/llvm/llvm-project/commit/0e743ecca018e9fa7482dc8bec62eae8cd0c929b
DIFF: https://github.com/llvm/llvm-project/commit/0e743ecca018e9fa7482dc8bec62eae8cd0c929b.diff
LOG: VPlan/PatternMatch: introduce m_c_Mul (NFC) (#93950)
Introduce a commutative version of m_Mul, and simplify a usage based on
it.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
index 0587468807435..d6b4acb2bdba2 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<Instruction::Mul, Op0_t, Op1_t>(Op0, Op1);
}
+template <typename Op0_t, typename Op1_t>
+inline AllBinaryRecipe_match<Op0_t, Op1_t, Instruction::Mul,
+ /* Commutative =*/true>
+m_c_Mul(const Op0_t &Op0, const Op1_t &Op1) {
+ return m_Binary<Instruction::Mul, Op0_t, Op1_t, true>(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 ab3b5cf2b9dab..8ec67eb2f54bd 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);
}
More information about the llvm-commits
mailing list