[llvm] [LV] Move condition to VPPartialReductionRecipe::execute (PR #166136)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 10 08:33:29 PST 2025
================
@@ -311,18 +311,27 @@ VPPartialReductionRecipe::computeCost(ElementCount VF,
std::optional<unsigned> Opcode;
VPValue *Op = getVecOp();
uint64_t MulConst;
+
+ InstructionCost CondCost = 0;
+ if (isConditional()) {
+ CmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE;
+ auto *VecTy = Ctx.Types.inferScalarType(Op);
+ auto *CondTy = Ctx.Types.inferScalarType(getCondOp());
+ CondCost = Ctx.TTI.getCmpSelInstrCost(Instruction::Select, VecTy, CondTy,
+ Pred, Ctx.CostKind);
+ }
+
// If the partial reduction is predicated, a select will be operand 1.
// If it isn't predicated and the mul isn't operating on a constant, then it
// should have been turned into a VPExpressionRecipe.
// FIXME: Replace the entire function with this once all partial reduction
// variants are bundled into VPExpressionRecipe.
- if (!match(Op, m_Select(m_VPValue(), m_VPValue(Op), m_VPValue())) &&
- !match(Op, m_Mul(m_VPValue(), m_ConstantInt(MulConst)))) {
+ if (!match(Op, m_Mul(m_VPValue(), m_ConstantInt(MulConst)))) {
----------------
sdesmalen-arm wrote:
There is only a `m_ConstantInt()` that takes a `uint64_t&`, so it can't be simplified.
https://github.com/llvm/llvm-project/pull/166136
More information about the llvm-commits
mailing list