Page MenuHomePhabricator

[ARM] MVE VPT Block Pass
ClosedPublic

Authored by SjoerdMeijer on Jun 13 2019, 3:12 AM.

Details

Summary

Initial commit of a new pass to create vector predication blocks, called VPT
blocks, that are supported by the Armv8.1-M MVE architecture.

This is a first naive implementation. I.e., for 2 consecutive predicated
instructions I1 and I2, for example, it will generate 2 VPT blocks:

VPST
I1
VPST
I2

A more optimal implementation would obviously put instructions in the same VPT
block when they are predicated on the same condition and when it is allowed to
do this:

VPTT
I1
I2

We will address this optimisation with follow up patches when the groundwork is
in. Creating VPT Blocks is very similar to IT Blocks, which is the reason I
added this to Thumb2ITBlocks.cpp. This allows reuse of the def use analysis
that we need for the more optimal implementation.

VPT blocks cannot be nested in IT blocks, and vice versa, and so these 2 passes
cannot interact with each other. Instructions allowed in VPT blocks must
be MVE instructions that are marked as VPT compatible.

This depends on D62669 because of the VPST tablegen instruction description.

Diff Detail

Repository
rL LLVM

Event Timeline

SjoerdMeijer created this revision.Jun 13 2019, 3:12 AM
SjoerdMeijer edited the summary of this revision. (Show Details)Jun 13 2019, 3:13 AM

Obviously a test is missing here. I will have a look what is easier: extract a few tablegen instructions descriptions from later patches so that we can create/add a test here, or we can wait for the later patches to be in.
Also, the pass will run, but won't trigger because there are no instructions yet that have getVPTInstrPredicate.

D62669 includes a few VPT predicable MVE instructions to test the assembly side of this, is that enough to add some MIR tests for this?

llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
395 ↗(On Diff #204466)

Can this one be a range-base for loop?

samparker added inline comments.Jun 14 2019, 12:48 AM
llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
369 ↗(On Diff #204466)

What's 8? Can we use an enum from somewhere?

SjoerdMeijer marked an inline comment as done.Jun 14 2019, 1:02 AM

D62669 includes a few VPT predicable MVE instructions to test the assembly side of this, is that enough to add some MIR tests for this?

Yep, nice one, will do.

llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
369 ↗(On Diff #204466)

That is the Mask Value (0b1000) for the VPST instruction as defined in the ARM ARM, see section B5.6. Predication/conditional execution. I'm not sure there's an enum for this, but will have a look. I will at least rename and comment on the Mask value here.

395 ↗(On Diff #204466)

easy piecy lemon squeezy. :-)

  • registered the pass,
  • so that I could create and add a MIR test,
  • and wrote a range based for-loop.
samparker added inline comments.Jun 14 2019, 1:21 AM
llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
369 ↗(On Diff #204466)

Ah yes, cheers. Probably worth creating an enum for the values in Table Rvwgt and have it live where ever ARMVCC is defined.

simon_tatham added inline comments.Jun 14 2019, 1:26 AM
llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
369 ↗(On Diff #204466)

I don't know of an enum for it, but as of the recent D63219, there's a comment explaining the format in ARMAsmParser::ParseInstruction.

363 ↗(On Diff #204719)

I suggest adding an assertion checking that the predicate is not ARMVCC::Else.

(The idea of that enum is that None, Then and Else are for use when handling assembly language: they correspond to the three possible suffixes "", "t" and "e" on the mnemonic. So when instructions are read from assembly source or disassembled from object code, you expect to see a mixture whenever there's a long VPT block. But in code generation, I hope we'll never generate an Else as input to this pass – though once this pass becomes able to generate nontrivial blocks, there will surely have to be Else-tagged instructions in its output, so that the clang -S output has the right suffixes on the mnemonics.

Thanks for your suggestion and explanation Simon. I have shamelessly almost literally copied and added it as a comment as I think that's very useful.

I have also added an enum declaration, locally for now, as I think I indeed need it later.

This revision is now accepted and ready to land.Jun 14 2019, 2:29 AM
Closed by commit rL363370: [ARM] MVE VPT Block Pass (authored by SjoerdMeijer, committed by ). · Explain WhyJun 14 2019, 4:44 AM
This revision was automatically updated to reflect the committed changes.