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

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 07:11:06 PDT 2026


================
@@ -473,6 +473,31 @@ 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()))) {
+        addUniformForAllParts(ALM);
+        ALM->setOperand(2, Plan.getConstantInt(64, UF));
+        continue;
+      }
+    }
+
+    if (match(&R, m_ExtractSubvectorForPart(m_VPValue(Op0), m_VPValue(Op1)))) {
+      VPRecipeBase *InsertPt = &R;
+      for (unsigned Part = 1; Part != UF; ++Part) {
+        auto *Ext = new VPInstruction(VPInstruction::ExtractSubvectorForPart,
+                                      {Op0, Plan.getConstantInt(64, Part)});
+        Ext->insertAfter(InsertPt);
+        addRecipeForPart(&R, Ext, Part);
+        InsertPt = Ext;
+      }
+      continue;
+    }
----------------
MacDue wrote:

nit: You should be able to handle this alongside e.g. `FirstOrderRecurrenceSplice` as:

```suggestion
    if (match(&R, m_VPInstruction<VPInstruction::ExtractSubVectorForPart>(
                      m_VPValue(Op), m_VPValue()))) {
      Copy->setOperand(0, getValueForPart(Op, Part));
      Copy->setOperand(1, getConstantInt(Part));
      continue;
    }
```

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


More information about the llvm-commits mailing list