[llvm] [LV] Vectorize selecting last IV of min/max element. (PR #141431)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 04:42:17 PDT 2025
Mel-Chen wrote:
I took the time to look at more examples. From what I’ve seen so far, deferring the decision to use the first or last index to VPlan seems beneficial. However, deferring the identification of min/max recurrence phis doesn’t appear to offer any clear advantage.
Would it be possible to still identify min/max recurrences during the legality stage, but postpone validating the interaction between the recurrence phi and FindIV until VPlan construction?
My reasoning is:
1. Supporting min/max recurrences with loop-exiting users in scalable vectors is important to us. There’s a large-trip-count case in the SPEC benchmark suite that falls into this category. Early detection of min/max recurrence could help LoopVectorizationLegality::canFoldTailByMasking() behave more effectively. Or enable tail folding with live-outs before this patch lands.
2. The current approach builds VPlans even for phis that are clearly not recurrences and not related to min/max at all. But why build a VPlan for a loop that’s already known to be unvectorizable?
Also, I noticed that by deferring recurrence detection to VPlan, we now need to check more types of recipes. This appears to introduce additional complexity.
https://github.com/llvm/llvm-project/pull/141431
More information about the llvm-commits
mailing list