[llvm] [LV] Vectorize selecting last IV of min/max element. (PR #141431)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 18 05:54:01 PST 2025
================
@@ -8162,13 +8174,19 @@ VPRecipeBase *VPRecipeBuilder::tryToCreateWidenRecipe(VPSingleDefRecipe *R,
getScalingForReduction(RdxDesc.getLoopExitInstr()).value_or(1);
PhiRecipe = new VPReductionPHIRecipe(
Phi, RdxDesc.getRecurrenceKind(), *StartV, CM.isInLoopReduction(Phi),
- CM.useOrderedReductions(RdxDesc), ScaleFactor);
- } else {
+ CM.useOrderedReductions(RdxDesc), ScaleFactor,
+ RdxDesc.isPhiMultiUse());
+ } else if (Legal->isFixedOrderRecurrence(Phi)) {
// TODO: Currently fixed-order recurrences are modeled as chains of
// first-order recurrences. If there are no users of the intermediate
// recurrences in the chain, the fixed order recurrence should be modeled
// directly, enabling more efficient codegen.
PhiRecipe = new VPFirstOrderRecurrencePHIRecipe(Phi, *StartV);
+ } else {
+ // Failed to identify phi as reduction or fixed-order recurrence. Keep the
+ // original VPWidenPHIRecipe for now, to be legalized later if possible.
----------------
ayalz wrote:
Reasonable to assert this new last else case involves a max/min reduction w/ multiple uses?
https://github.com/llvm/llvm-project/pull/141431
More information about the llvm-commits
mailing list