[llvm] [LV] Use wide lane masks as the canonical form when tail-folding & interleaving (PR #209484)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 03:58:03 PDT 2026


================
@@ -472,6 +478,19 @@ void UnrollState::unrollBlock(VPBlockBase *VPB) {
       continue;
     }
 
+    if (match(&R,
+              m_ActiveLaneMask(m_VPValue(), m_VPValue(Op1), m_VPValue(Op2)))) {
+      auto *ALM = cast<VPInstruction>(&R);
+      auto *User = ALM->getSingleUser();
+      // Widen ActiveLaneMask when used for control flow.
+      if (User && match(User, m_ExtractSubvectorForPart(m_Specific(ALM),
+                                                        m_ZeroInt()))) {
----------------
paulwalker-arm wrote:

If `ExtractSubvectorForPart` has value separately then that's great, but it should be added for those use cases rather than potentially being wedged in here for connivence.

What I don't like about the current approach is that you need to construct a very specific VPInstruction sequence, that latter has to be identified, so the control-flow mask is constructed correctly. That feels wrong to me as I believe we should always be able to handle VPInstructions in isolation.

That is why I see two different active.lane.mask operations.  One that represents a single interleave factor and is unrolled as you'd expect, and a second that represents the entire vector loop that is not duplicated when unrolled but instead widened with each part extracting their section from it. Doing this means when either is interrogated the semantics of the operation remain clear.

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


More information about the llvm-commits mailing list