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

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 20:27:52 PDT 2025


Mel-Chen wrote:

> Updated the latest version to perform the check for the pattern in VPlan.
> 
> The main idea is that we allow unclassified phis in legal and hand off the VPlan to check if we can the remaining VPWidenPHIRecipes to min/max reductions used by FindLast/FirstIV. The current patch just supports the FindLastIV case, to not make it depend on #140451.
> 
> It now depends on #142322 to make it easy to create VPReductionPHIRecipes from VPlan w/o RecurrenceDescriptor. WDYT?

#142322 is good and will definitely be useful in the future. However, I’m a bit confused about VPlanTransforms::legalizeUnclassifiedPhis. Do we have any plans to move legality checks into the VPlan transformation phase? What are the benefits of doing this? 
I’m concerned that identifying min/max recurrences so late might limit future support for in-loop min/max reductions. Also, when min/max recurrences have LoopExitInstr, would this approach prevent us from using tail folding for vectorization?

Separately, I submitted #141467 and #142335, but they haven’t received any review yet. I’d like to understand if there are any major design issues with my patches that are preventing them from being accepted.

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


More information about the llvm-commits mailing list