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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 11:40:40 PST 2025


================
@@ -933,7 +933,8 @@ bool VPlanTransforms::handleMaxMinNumReductions(VPlan &Plan) {
 
     // If we exit early due to NaNs, compute the final reduction result based on
     // the reduction phi at the beginning of the last vector iteration.
-    auto *RdxResult = findComputeReductionResult(RedPhiR);
+    auto *RdxResult =
+        findReductionUser(RedPhiR, VPInstruction::ComputeReductionResult);
----------------
fhahn wrote:

Ah I see, added `llvm/test/Transforms/LoopVectorize/select-fmax-last-index.ll` and `llvm/test/Transforms/LoopVectorize/select-fmin-last-index.ll` to the PR, covering both argfmax/argfmin with and without fast-math flags, thanks.

Currently anything other than integer min/max reductions is rejected earlier on.

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


More information about the llvm-commits mailing list