[llvm] [LV] Keep predicate select when optimizeFindIVReductions when folding tail. (PR #191166)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 05:08:07 PDT 2026


================
@@ -5911,7 +5917,8 @@ void VPlanTransforms::optimizeFindIVReductions(VPlan &Plan,
     DebugLoc ExitDL = RdxResult->getDebugLoc();
     VPBuilder MiddleBuilder(RdxResult);
     VPValue *ReducedIV = MiddleBuilder.createNaryOp(
-        VPInstruction::ComputeReductionResult, FindLastSelect, Flags, ExitDL);
+        VPInstruction::ComputeReductionResult,
+        HeaderMask ? PredSelect : FindLastSelect, Flags, ExitDL);
----------------
ElvisWang123 wrote:

Right the FindLastSelect is updated. I also updated the operand of the predicated select to the new FindLastSelect.

The test in `iv-select-cmp-fold-tail.ll` will trigger `IVExpressionToSink`

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


More information about the llvm-commits mailing list