Skip to content

[LV][EVL] Try to put it close to addActiveLaneMask() #153144

@Mel-Chen

Description

@Mel-Chen

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.

cc. @alexey-bataev @lukel97 @arcbbb @preames @LiqinWeng

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions