[llvm-branch-commits] [llvm] [LV] Add ExtNegatedMulAccReduction expression type (PR #160154)
Sander de Smalen via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Sep 26 09:09:44 PDT 2025
================
@@ -3541,17 +3547,24 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
IsMulAccValidAndClampRange(RecipeA->getOpcode() ==
Instruction::CastOps::ZExt,
Mul, RecipeA, RecipeB, nullptr)) {
+ if (Sub)
+ return new VPExpressionRecipe(
+ RecipeA, RecipeB, Mul,
+ cast<VPWidenRecipe>(Sub->getDefiningRecipe()), Red);
return new VPExpressionRecipe(RecipeA, RecipeB, Mul, Red);
}
// Match reduce.add(mul).
- if (IsMulAccValidAndClampRange(true, Mul, nullptr, nullptr, nullptr))
+ // TODO: Add an expression type for this variant with a negated mul
+ if (!Sub &&
+ IsMulAccValidAndClampRange(true, Mul, nullptr, nullptr, nullptr))
return new VPExpressionRecipe(Mul, Red);
}
// Match reduce.add(ext(mul(ext(A), ext(B)))).
// All extend recipes must have same opcode or A == B
// which can be transform to reduce.add(zext(mul(sext(A), sext(B)))).
- if (match(VecOp, m_ZExtOrSExt(m_Mul(m_ZExtOrSExt(m_VPValue()),
- m_ZExtOrSExt(m_VPValue()))))) {
+ // TODO: Add an expression type for this variant with a negated mul
+ if (!Sub && match(VecOp, m_ZExtOrSExt(m_Mul(m_ZExtOrSExt(m_VPValue()),
----------------
sdesmalen-arm wrote:
nit: rather than doing `!Sub &&` here, I would just have an explicit `if (Sub) return nullptr;` in case other cases get added in the future that may also not support the `sub`.
https://github.com/llvm/llvm-project/pull/160154
More information about the llvm-branch-commits
mailing list