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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 03:27:31 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())));
----------------
fhahn wrote:

Not at this point; this runs before we attach the mask. For the later uses, we currently either never create alias-masks (EVL path) or it is only used for optimizations.

I think we can also separately move the attaching of the mask later. 

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


More information about the llvm-commits mailing list