<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/153144>153144</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LV][EVL] Try to put it close to addActiveLaneMask()
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
Mel-Chen
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Mel-Chen
</td>
</tr>
</table>
<pre>
This work try to move EVL lowering into tryToBuildVPlanWithVPRecipes for removing the following TODO.
```
// TODO: try to put it close to addActiveLaneMask().
```
The ultimate goal of this work is to move addExplicitVectorLength to:
```
if (useActiveLaneMask(Style)) {
...
} else if (CM.foldTailWithEVL() && !Plan->hasScalarVFOnly()) {
VPlanTransforms::runPass(VPlanTransforms::addExplicitVectorLength, *Plan,
CM.getMaxSafeElements());
}
```
As an intermediate step, it will first be moved to the beginning of the following for loop:
```
for (ElementCount VF = MinVF; ElementCount::isKnownLT(VF, MaxVFTimes2);) {
VFRange SubRange = {VF, MaxVFTimes2};
if (auto Plan = tryToBuildVPlanWithVPRecipes(
std::unique_ptr<VPlan>(VPlan0->duplicate()), SubRange, &LVer)) {
/* Move VPlanTransforms::addExplicitVectorLength to HERE*/
bool HasScalarVF = Plan->hasScalarVFOnly();
// Now optimize the initial VPlan.
if (!HasScalarVF)
VPlanTransforms::runPass(VPlanTransforms::truncateToMinimalBitwidths,
*Plan, CM.getMinimalBitwidths());
//VPlanTransforms::runPass(VPlanTransforms::optimize, *Plan);
VPlanTransforms::runPass(VPlanTransforms::optimize1, *Plan);
// TODO: try to put it close to addActiveLaneMask().
if (CM.foldTailWithEVL() && !HasScalarVF)
VPlanTransforms::runPass(VPlanTransforms::addExplicitVectorLength,
*Plan, CM.getMaxSafeElements());
VPlanTransforms::runPass(VPlanTransforms::optimize2, *Plan);
assert(verifyVPlanIsValid(*Plan) && "VPlan is invalid");
VPlans.push_back(std::move(Plan));
}
VF = SubRange.End;
}
```
and then finally into tryToBuildVPlanWithVPRecipes.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVklv6zYQ_jX0ZRBBorwefPAmvKJ2EySGenygpJHFPop0ScqO--sLavGSOGmbVyBALHM4y7eMxYzhO4k4JYM5oXSD4mFRoCSUksGyxypbKD3tvu0lKjtNtwU3cFT6B1h9AqugVAeEVbwGoY6oudwBl1a5062aV1xk8ZNg8ndui_jpGVO-RwO50qCxVAcXbguEXAmhju5p-7h89Ig_I0O__fNnQGhEaFSfkXDWVd5XFriFVCiD7pll2Sy1_IBrJnHDzA9Cx4RO3mbbFgiVsLxkFmGnmACVgz2Pxc15KpZlq9e94Cm3MaZW6TXKnS3AKhLO3vYIADwHQseVwXdtvNiTQEInhE6AjOZtPAB4ntc-kNESUBhssyw2Xq5EtmVcOOxW8bqZBggdEjoEQgOH6wMJVwUzLykTTMfRoxSnJu6qUk3AVjNpcqVL43oPZ7qST8wYQsd3jz8YndAFEDpzNwhduOSLjbdDu2GvLyzHlcASpTXnFkg4v4z3BrGZASadWFCXmHHHhrG4dyW4hSMXAnKujYUEazoyx4sTS4I7LqUTS03ctXqcsIRSe6eSOwS5Y0LHbZsLVUkLcQQkXMKGyzgi4RyuDxssuPlVqqNcbx1Yketvw17jaMtLNLQd8g2vcfTM5A7hpUqaD64EGc3fXx8tLxh1CmKVVeAwrq995iQHtD8DY7Om1UryPyv8vreahIs6nISrjmPfiSWrHKvM4oUjujj32fA7XMeobzR0NuEMNs4Z9zX1sV8Avq2eV4TOXJImXaKUgG8X6dazfi7pK6Cg2wm_qSOoveUl_wtrMXDJLWei6dC7utBgS2hwVdRl_aJDrK6kw3GrNlzykok5t0ee2cK0zrj4pDPJu7hblzQTfaWXDoAbe3ZpfyZhcDfjLQNf38q3zPyLjff_MPfxbrtP2-e77WfgpXfhZcagtoSOD6h5fqoz_GJiJnhWF-_CL8DQOsb9dHF5aOLomw6Nt69M8T1hqSPgvDDcYiV03DVwS3Gzs7uN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