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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 27 04:10:06 PST 2026


================
@@ -4158,6 +4170,26 @@ 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 &&
+           "MulAccumulateReduction from an FMul must accumulate into an FAdd "
+           "instruction");
+    auto *RecipeA = dyn_cast<VPWidenCastRecipe>(A);
+    auto *RecipeB = dyn_cast<VPWidenCastRecipe>(B);
+    auto *FMul = dyn_cast<VPWidenRecipe>(VecOp);
----------------
fhahn wrote:

If `dyn_cast<VPWidenRecipe>(VecOp);` works, I'd expect to `cast<VPWidenRecipe>(VecOp);` to also work?

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


More information about the llvm-commits mailing list