[llvm] [LV] Enable the exit value optimization via SCEV for tail folding. (PR #210928)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 05:23:33 PDT 2026


================
@@ -1125,8 +1125,49 @@ optimizeLatchExitInductionUser(VPlan &Plan, VPValue *Op,
   return nullptr;
 }
 
+static VPValue *optimizeLatchExitIVUserViaSCEV(VPlan &Plan, VPValue *Op,
+                                               PredicatedScalarEvolution &PSE,
+                                               VPValue *ResumeTC,
+                                               const Loop *L) {
+  VPValue *Incoming;
+  if (!match(Op, m_ExtractLastLaneOfLastPart(m_VPValue(Incoming)))) {
+    VPValue *Mask;
+    if (!match(Op, m_ExtractLane(m_LastActiveLane(m_VPValue(Mask)),
+                                 m_VPValue(Incoming))) ||
+        !match(Mask, m_HeaderMask()))
+      return nullptr;
+  }
----------------
lukel97 wrote:

Do we need to match `Mask`? Can we not inline it into `m_LastActiveLane(m_HeaderMask())`. I think we can also use `m_CombineOr`?

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


More information about the llvm-commits mailing list