[llvm] Reapply "[LV] Enable scalable FindLast on RISCV. (#184931)" (PR #190938)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 09:26:50 PDT 2026


================
@@ -3219,6 +3219,31 @@ void VPlanTransforms::optimizeEVLMasks(VPlan &Plan) {
   }
 }
 
+// Fixup FindLast reductions. In RISCV, the last 2 iterations might not operate
+// on full vector lanes. So we need to put the predicated select after FindIV
+// select in the loop body to prevent poison values in reduction phi.
+static void fixupFindIVForEVL(VPlan &Plan) {
----------------
fhahn wrote:

Right, but it would also be an issue if we have a similar select for another reduction kind? Even if if may not trigger currently, if we an handle/check the general pattern independent of the recurrence kind, that may prevent future similar bugs?

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


More information about the llvm-commits mailing list