[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 08:42:55 PST 2025


================
@@ -818,13 +818,13 @@ void VPlanTransforms::addMinimumVectorEpilogueIterationCheck(
   Branch->setMetadata(LLVMContext::MD_prof, BranchWeights);
 }
 
-/// If \p RedPhiR is used by a ComputeReductionResult recipe, return it.
-/// Otherwise return nullptr.
-static VPInstruction *
-findComputeReductionResult(VPReductionPHIRecipe *RedPhiR) {
-  auto It = find_if(RedPhiR->users(), [](VPUser *U) {
+/// If \p RedPhiR is used by a VPInstruction with \p Opcode, return it.
+/// Otherwise return nullptr;
+static VPInstruction *findReductionUser(VPReductionPHIRecipe *RedPhiR,
+                                        unsigned Opcode) {
+  auto It = find_if(RedPhiR->users(), [Opcode](VPUser *U) {
     auto *VPI = dyn_cast<VPInstruction>(U);
-    return VPI && VPI->getOpcode() == VPInstruction::ComputeReductionResult;
+    return VPI && VPI->getOpcode() == Opcode;
----------------
fhahn wrote:

Yes I added 2 variants: `findUser`, which takes a generic matcher (`findUser`,  and `findUserVPInstruction`).

I'll check for other potential users of the functions in a follow-up

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


More information about the llvm-commits mailing list