[llvm] [VPlan] Constant-fold ActiveLaneMask intrinsics (PR #208852)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 03:32:38 PDT 2026
================
@@ -1349,6 +1349,31 @@ VPIRValue *vputils::tryToFoldLiveIns(VPSingleDefRecipe &R,
case Instruction::ExtractElement:
assert(!Ops[0]->getType()->isVectorTy() && "Live-ins should be scalar");
return Ops[0];
+ case VPInstruction::ActiveLaneMask:
+ case VPInstruction::WideActiveLaneMask: {
+ uint64_t Multiplier = 1;
+ if (Opcode == VPInstruction::WideActiveLaneMask) {
+ // Optimizing WideALM can only happen after the Plan is unrolled.
+ if (!Plan.isUnrolled())
+ return nullptr;
+ Multiplier = cast<ConstantInt>(Ops[2])->getZExtValue();
+ Ops.pop_back();
+ }
+ Type *I1Ty = IntegerType::getInt1Ty(Plan.getContext());
+ ElementCount MaxVF =
+ *max_element(Plan.vectorFactors(), ElementCount::isKnownLT) *
----------------
artagnon wrote:
Ah, this was due to a comment dropped in the rebase: we create separate VPlans for the fixed-vector and scalable-vector cases, and rely on this property. >From LoopVectorizationPlanner::plan:
```cpp
buildVPlans(*VPlan1, ElementCount::getFixed(1), MaxFactors.FixedVF);
buildVPlans(*VPlan1, ElementCount::getScalable(1), MaxFactors.ScalableVF);
```
https://github.com/llvm/llvm-project/pull/208852
More information about the llvm-commits
mailing list