[llvm-branch-commits] [llvm] [LoopVectorizer] Bundle partial reductions inside VPMulAccumulateReductionRecipe (PR #136173)

Florian Hahn via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 29 10:27:09 PDT 2025


================
@@ -2432,12 +2437,40 @@ static void tryToCreateAbstractReductionRecipe(VPReductionRecipe *Red,
   Red->replaceAllUsesWith(AbstractR);
 }
 
+/// This function tries to create an abstract recipe from a partial reduction to
+/// hide its mul and extends from cost estimation.
+static void
+tryToCreateAbstractPartialReductionRecipe(VPPartialReductionRecipe *PRed) {
+  if (PRed->getOpcode() != Instruction::Add)
+    return;
+
+  VPRecipeBase *BinOpR = PRed->getBinOp()->getDefiningRecipe();
+  auto *BinOp = dyn_cast<VPWidenRecipe>(BinOpR);
+  if (!BinOp || BinOp->getOpcode() != Instruction::Mul)
+    return;
----------------
fhahn wrote:

```suggestion
  VPRecipeBase *BinOpR = PRed->getBinOp()->getDefiningRecipe();
  auto *BinOp = dyn_cast<VPWidenRecipe>(BinOpR);
  if (!match(PRed->getBinOp(), m_Mul(m_ZExtOrSExt(Ext0), m_ZExtOrSExt(Ext1))))`
    return;
```

Could you use pattern matching to combine some of the checks?

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


More information about the llvm-branch-commits mailing list