[llvm] [LV] Vectorize selecting last IV of min/max element. (PR #141431)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 26 22:16:17 PDT 2025


fhahn wrote:

> > > WDYT?
> > 
> > 
> > Thanks! Yes, this is roughly what I hoped. But I think we can achieve this without introducing new recurrence kinds.
> > I suggest separating recurrence and reduction patterns. That is, first we identify the recurrence, and then determine whether this recurrence is a reduction. In RecurrenceDescriptor, we can temporarily add a bool isReduction to distinguish the two. This approach may involve significant changes, with the final goal of replacing the existing reduction detection method. But we can start by trying it on min/max reductions.
> 
> I'll try that thanks. One thing I am a bit concerned is how we best make sure that all users perform the necessary extra checks.
> 

The latest update replaced the duplicated opcodes with a flag for multi-uses. I think down the line we probably just want to check that in VPlan, but it's not trivial, as there may be multiple uses if a cmp/select pattern is used.

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


More information about the llvm-commits mailing list