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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 11 05:54:36 PST 2025


fhahn wrote:

> > Hmm, with this change IIUC we now assume that the cost of partial reduction with and without selects will be the same. Is that correct in all cases?
> 
> Not sure I missed the response to the comment, but it is still not entirely clear how the cost of the selects is properly accounted for. As far as I can tell, we now create a VPExpressionRecipe with a conditional VPPartialReductionRecipe, but dont account for the reduction being conditional neither when creating VPExpressionRecipe nor in VPExpressionRecipe::computeCost.
> 
> As a consequence, aren't we assuming a cost of 1 for VF = 16 for the whole ext/mul/select/reduced in the test case added in `llvm/test/Transforms/LoopVectorize/AArch64/vplan-printing.ll`, while it cannot be lowered to a single partial reduction instruction, with or without SVE? https://llvm.godbolt.org/z/ETas69vna

Looking a bit more into this, I couldn't find a case where forming predicated partial reduction is actually benefifical, so unless I missed soemthing, it might be simplest to just avoid forming them in such cases in the first place for now? https://github.com/llvm/llvm-project/pull/167506

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


More information about the llvm-commits mailing list