[llvm] [LV] Use VPReductionRecipe for partial reductions (PR #144908)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 24 02:30:08 PDT 2025
================
@@ -2563,6 +2495,30 @@ InstructionCost VPReductionRecipe::computeCost(ElementCount VF,
std::optional<FastMathFlags> OptionalFMF =
ElementTy->isFloatingPointTy() ? std::make_optional(FMFs) : std::nullopt;
+ if (isPartialReduction()) {
+ using namespace llvm::VPlanPatternMatch;
+ VPValue *Mul = getVecOp();
+ // Some chained partial reductions used for complex numbers will have a
+ // negation between the mul and reduction. This extracts the mul from that
+ // pattern to use it for further checking.
+ match(Mul, m_Binary<Instruction::Sub>(m_SpecificInt(0), m_VPValue(Mul)));
+ if (match(Mul,
+ m_Mul(m_ZExtOrSExt(m_VPValue()), m_ZExtOrSExt(m_VPValue())))) {
----------------
SamTebbs33 wrote:
Done. Using the simple case stopped mixed extension partial reductions from being turned into `VPMulAccumulateRecipe` so I had to add support for mixed extension types to that class which has made the change a bit bigger, but I hope it's more correct now.
https://github.com/llvm/llvm-project/pull/144908
More information about the llvm-commits
mailing list