[llvm] [VPlan] Split out optimizeEVLMasks. NFC (PR #174925)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 10 02:50:48 PST 2026
================
@@ -2995,8 +2979,45 @@ 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
+ VPValue *HeaderMask = nullptr, *EVL = nullptr;
+ for (VPRecipeBase &R : *Plan.getVectorLoopRegion()->getEntryBasicBlock()) {
+ if (match(&R, m_SpecificICmp(CmpInst::ICMP_ULT, m_StepVector(),
+ m_VPValue(EVL))) &&
+ match(EVL, m_EVL(m_VPValue()))) {
----------------
lukel97 wrote:
I don't think we have any guarantee or invariant that EVL is the only user of AVL. What would make this nicer is if we copied over the two argument m_Value from PatternMatch.h so we can match and capture the value in the same matcher:
```c++
/// Match against the nested pattern, and capture the value if we match.
template <typename MatchTy>
inline bind_and_match_ty<const Value, MatchTy> m_Value(const Value *&V,
const MatchTy &Match) {
return {V, Match};
}
```
Would you be interested in implementing that as a follow up?
https://github.com/llvm/llvm-project/pull/174925
More information about the llvm-commits
mailing list