This is an archive of the discontinued LLVM Phabricator instance.

[LoopVectorize] Return both fixed and scalable Max VF from computeMaxVF.
AbandonedPublic

Authored by sdesmalen on Feb 4 2021, 5:38 AM.

Details

Reviewers
None
Summary

This patch introduces a new class, MinMaxVFCandidates, that holds
the possible maximum vectorization factors that have been computed. The
algorithm guarantees there is always at least one maximum VF (in worst
case ElementCount::getFixed(1) for scalarization), but may have both a
fixed MaxVF and a scalable MaxVF.

This patch is intended to be a non-functional change for now,
because LoopVectorizationPlanner::plan doesn't actually use the
scalable MaxVF yet to automatically pick a scalable VPlan
(at least not beyond the UserVF if that's given).

This patch is a preparatory patch with the ultimate goal of making
computeMaxVF() return both a max fixed VF and a max scalable VF,
so that selectVectorizationFactor() can pick the most cost-effective
vectorization factor.

Diff Detail

Event Timeline

sdesmalen created this revision.Feb 4 2021, 5:38 AM
sdesmalen requested review of this revision.Feb 4 2021, 5:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2021, 5:38 AM
Herald added a subscriber: vkmr. · View Herald Transcript

Hi Sander, one question OptionalVFCandidates::addMaxVF combines using the maximum but AFAICT it is not used in a loop. Maybe you plan to "update" the corresponding VF values (scalable and/or fixed) in other places (not shown in the current patch, yet)?

Hi Sander, one question OptionalVFCandidates::addMaxVF combines using the maximum but AFAICT it is not used in a loop. Maybe you plan to "update" the corresponding VF values (scalable and/or fixed) in other places (not shown in the current patch, yet)?

Hi Roger, thanks for having a look! This patch is part of a series that allows the vectorizer to reason about a suitable VF (fixed or scalable):

  • D96021, D96022, D96023, D96025 are mostly NFC changes that restructure the code to make it easier to reason about both fixed/scalable VFs (and adds the OptionalVFCandidates class).
  • D96546 then adds a function genAllPowerOfTwoFactorsUptoMaxFactors, which uses two loops to generate all power-of-two VFs upto the max-VFs. It is still more or less NFC, because it doesn't yet consider the scalable VF for vectorization.
  • D96547 let's the cost-model reason about those scalable VFs, so that it can pick a scalable VF as the most profitable VF.
sdesmalen updated this revision to Diff 324643.Feb 18 2021, 8:08 AM
sdesmalen edited the summary of this revision. (Show Details)

Rebased

sdesmalen updated this revision to Diff 324660.Feb 18 2021, 8:44 AM

Removed unrelated change.

sdesmalen updated this revision to Diff 327900.Mar 3 2021, 1:47 PM

Rebased patch.

sdesmalen abandoned this revision.Mar 12 2021, 7:40 AM

Abandoning patch in favour of new patch series (see D98509)

bmahjour removed a subscriber: bmahjour.Mar 12 2021, 9:21 AM