[llvm] [LV] Choose best reduction for VPlan (PR #166138)

Sushant Gokhale via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 02:16:51 PST 2025


sushgokh wrote:

> I think we already query the cost of the partial reduction when we collect them, right? Woult it be possible to reject non-profitable cases early on?

As far as I understand, a partial reduction recipe is first created and then converted to abstract expression recipe if its profitable.

Firstly, the cost computation is going wrong I believe: 
```
return ExtRedCost.isValid() && ExtRedCost < ExtCost + RedCost;
```
The `RedCost` should be the cost of multiplying and extending as if we are using a widening recipe but its not computing this rightly.

Secondly, even if the computation goes right here, we dont get the right scaling factor for the reduction phi. So, my thought process is we should change the scaling factor only if the partial reduce recipe is converted to abstract recipe otherwise not(i.e. it should be as good as a widen recipe ?)

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


More information about the llvm-commits mailing list