[llvm] [LV] Move condition to VPPartialReductionRecipe::execute (PR #166136)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 01:27:33 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);
----------------
gbossu wrote:

So now we create the `select` directly using an IR builder, as opposed to creating a new recipe for it in `tryToCreatePartialReduction`. Was it that recipe that was preventing tail folding?

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


More information about the llvm-commits mailing list