[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 21 03:31:36 PDT 2026


================
@@ -1104,6 +1108,32 @@ Value *VPInstruction::generate(VPTransformState &State) {
 
     return Result;
   }
+  case VPInstruction::ExtractSubvectorForPart: {
+    Value *Src = State.get(getOperand(0));
+    Type *DstTy = VectorType::get(getScalarType(), State.VF);
+    unsigned Part = cast<VPConstantInt>(getOperand(1))->getZExtValue();
+
+    if (Src->getType() == DstTy)
+      return Src;
+
+    // If the VF is scalar & this is an extract of an active lane mask,
+    // generate an ICMP directly.
+    VPValue *Start, *TC;
+    if (State.VF.isScalar() &&
+        match(getOperand(0),
+              m_ActiveLaneMaskForControlFlow(m_VPValue(Start), m_VPValue(TC),
+                                             m_VPValue()))) {
+      Value *StartV = State.get(Start);
+      if (Part > 0)
+        StartV = Builder.CreateAdd(StartV, State.get(getOperand(1)));
+      return Builder.CreateCmp(CmpInst::Predicate::ICMP_ULT, StartV,
+                               State.get(TC));
+    }
----------------
MacDue wrote:

Not sure if it's any cleaner, but I another option would be a combine in `simplifyBranchConditionForVFAndUF` for: `ExtractSubvectorForPart(WideActiveLaneMask(), Part) => ActiveLaneMask`

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


More information about the llvm-commits mailing list