[llvm] [LV] Move condition to VPPartialReductionRecipe::execute (PR #166136)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 10 03:39:28 PST 2025
================
@@ -395,12 +395,18 @@ void VPPartialReductionRecipe::execute(VPTransformState &State) {
assert(getOpcode() == Instruction::Add &&
"Unhandled partial reduction opcode");
- Value *BinOpVal = State.get(getOperand(1));
- Value *PhiVal = State.get(getOperand(0));
+ Value *BinOpVal = State.get(getVecOp());
+ Value *PhiVal = State.get(getChainOp());
assert(PhiVal && BinOpVal && "Phi and Mul must be set");
Type *RetTy = PhiVal->getType();
+ if (isConditional()) {
+ Value *Cond = State.get(getCondOp());
+ Value *Zero = ConstantInt::get(BinOpVal->getType(), 0);
+ BinOpVal = Builder.CreateSelect(Cond, BinOpVal, Zero);
----------------
sdesmalen-arm wrote:
Yes, that's right. The matcher functions that try to match a VPExpression (for e.g. `reduce.add(mul(ext(a), ext(b)))`) did not account for any `Select` on the input, so a VPlan that has something like `reduce.add(select(pred, mul(ext(a), ext(b)), ..)` would not be recognised as a known/supported expression.
https://github.com/llvm/llvm-project/pull/166136
More information about the llvm-commits
mailing list