[llvm] [VPlan] Model initial header mask as region value. (PR #196199)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 05:26:27 PDT 2026


================
@@ -3672,9 +3681,13 @@ void VPlanTransforms::dropPoisonGeneratingRecipes(VPlan &Plan) {
 
   // We want to exclude the tail folding case, as we don't need to drop flags
   // for operations computing the first lane in this case: the first lane of the
-  // header mask must always be true.
-  auto IsNotHeaderMask = [&Plan](VPValue *Mask) {
-    return Mask && !vputils::isHeaderMask(Mask, Plan);
+  // header mask must always be true. For reverse memory accesses, the mask is
+  // wrapped in a Reverse, which is just a permutation of the header mask, so
+  // peel it off before checking. The header mask is still the abstract region
+  // value at this point (materialization happens later).
+  auto IsNotHeaderMask = [](VPValue *Mask) {
+    return Mask &&
+           !match(Mask, m_CombineOr(m_HeaderMask(), m_Reverse(m_HeaderMask())));
----------------
lukel97 wrote:

Can the header mask be and'ed with an IncomingAliasMask? I think the old users of `findHeaderMask` treat `(and orig-header-mask IncomingAliasMask)` also as the header mask.

Is it possible to materialize the IncomingAliasMask with the rest of the header mask so it's also part of the region value? Otherwise I presume we need to update every caller of findHeaderMask to also check for the IncomingAliasMask. 

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


More information about the llvm-commits mailing list