[llvm] [VPlan] Constant-fold ActiveLaneMask intrinsics (PR #208852)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 12:57:43 PDT 2026


================
@@ -1115,6 +1115,23 @@ VPIRValue *vputils::tryToFoldLiveIns(VPSingleDefRecipe &R,
     case Instruction::ExtractElement:
       assert(!Ops[0]->getType()->isVectorTy() && "Live-ins should be scalar");
       return Ops[0];
+    case VPInstruction::ActiveLaneMask: {
+      uint64_t Multiplier = cast<ConstantInt>(Ops[2])->getZExtValue();
+      Type *I1Ty = IntegerType::getInt1Ty(Plan.getContext());
+      if (Plan.hasScalableVF())
+        // We do not produce foldable scalable ALMs at the moment.
+        return nullptr;
+
+      // We do not produce ALMs foldable to false at the moment.
+      unsigned MaxVF = Multiplier * max_element(Plan.vectorFactors(),
+                                                ElementCount::isKnownLT)
+                                        ->getFixedValue();
+      if (auto *C = dyn_cast_if_present<Constant>(Folder.FoldIntrinsic(
----------------
artagnon wrote:

Fixed now, thanks :)

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


More information about the llvm-commits mailing list