[llvm] [VPlan] Move addExplicitVectorLength to tryToBuildVPlanWithVPRecipes (PR #166164)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 7 00:21:49 PST 2025
================
@@ -2617,8 +2621,40 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
return nullptr;
}
-/// Replace recipes with their EVL variants.
-static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
+void VPlanTransforms::optimizeMasksToEVL(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;
+
+ VPValue *EVL = HeaderMask->getOperand(1);
----------------
Mel-Chen wrote:
Do you have plan to create helper function like `static VPValue *findEVLMask(VPlan &Plan)`?
If not, could we do
```suggestion
// Find the EVL-based header mask if it exists: icmp ult step-vector, EVL
VPInstruction *HeaderMask = nullptr;
VPValue *EVL;
for (VPRecipeBase &R : *Plan.getVectorLoopRegion()->getEntryBasicBlock()) {
if (match(&R, m_ICmp(m_VPInstruction<VPInstruction::StepVector>(),
m_EVL(m_VPValue(EVL))))) {
HeaderMask = cast<VPInstruction>(&R);
break;
}
}
if (!HeaderMask)
return;
```
?
https://github.com/llvm/llvm-project/pull/166164
More information about the llvm-commits
mailing list