[llvm] Add LoopVectorizer support for `llvm.vector.partial.reduce.fadd` (PR #163975)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 16 03:13:39 PST 2025


================
@@ -3898,6 +3904,24 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
   VPRecipeBase *Sub = nullptr;
   VPValue *A, *B;
   VPValue *Tmp = nullptr;
+
+  // Try to match reduce.fadd(fmul(...)).
+  if (match(VecOp, m_FMul(m_VPValue(A), m_VPValue(B)))) {
+    assert(Opcode == Instruction::FAdd);
+    auto *RecipeA = dyn_cast_if_present<VPWidenCastRecipe>(A);
+    auto *RecipeB = dyn_cast_if_present<VPWidenCastRecipe>(B);
----------------
fhahn wrote:

```suggestion
    auto *RecipeA = dyn_cast<VPWidenCastRecipe>(A);
    auto *RecipeB = dyn_cast<VPWidenCastRecipe>(B);
```

A and B cannot be nullptr if the pattern matches

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


More information about the llvm-commits mailing list