[llvm] [VPlan] Split out optimizeEVLMasks. NFC (PR #174925)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 8 08:24:00 PST 2026
================
@@ -2995,8 +2979,42 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
return nullptr;
}
-/// Replace recipes with their EVL variants.
-static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
+/// Optimize away any EVL-based header masks to VP intrinsic based recipes.
+/// The transforms here need to preserve the original semantics.
+void VPlanTransforms::optimizeEVLMasks(VPlan &Plan) {
+ // Find the EVL-based header mask if it exists: icmp ult step-vector, EVL
+ VPInstruction *HeaderMask = nullptr;
+ for (VPRecipeBase &R : *Plan.getVectorLoopRegion()->getEntryBasicBlock()) {
+ if (match(&R, m_ICmp(m_VPInstruction<VPInstruction::StepVector>(),
+ m_EVL(m_VPValue())))) {
+ HeaderMask = cast<VPInstruction>(&R);
+ break;
+ }
+ }
+ if (!HeaderMask)
+ return;
+
+ VPTypeAnalysis TypeInfo(Plan);
+ VPValue *EVL = HeaderMask->getOperand(1);
+
+ for (VPUser *U : collectUsersRecursively(HeaderMask)) {
----------------
artagnon wrote:
collectUsersRecursively returns an rvalue from `takeVector`, which is fine if the users are read-only, but we eraseFromParent -- I think you need an lvalue.
https://github.com/llvm/llvm-project/pull/174925
More information about the llvm-commits
mailing list