This is an archive of the discontinued LLVM Phabricator instance.

[ARM][MVE] Tail predication conversion
ClosedPublic

Authored by samparker on Nov 7 2019, 5:53 AM.

Details

Summary

This patch modifies ARMLowOverheadLoops to convert a predicated vector low-overhead loop into a tail-predicatd one. This is currently a very basic conversion, with the following restrictions:

  • Operates only on single block loops.
  • The loop can only contain a single vctp instruction.
  • No other instructions can write to the vpr.
  • We only allow a subset of the mve instructions in the loop.

Most of the changes are because the logic has been moved around. We now have a LowOverheadLoop object to hold, track and check the current state of the loop and its legality.

Diff Detail

Event Timeline

samparker created this revision.Nov 7 2019, 5:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2019, 5:53 AM
samparker edited the summary of this revision. (Show Details)Nov 7 2019, 5:53 AM
SjoerdMeijer added inline comments.Nov 11 2019, 5:26 AM
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
46

Nit, perhaps: VPTMIs -> VPTUsers?

48

Looks like this TailPredicate is a boolean for "FoundVPT", so can we just use VCTP? Or perphaps at least change the name because it might be easy to confuse it with CannotTailPredicate?

98

nit: can defined -> can be defined / is defined

116

nit: else if (!FoundAllComponents())

306

nit: perhaps just return here?

314

and here

327

because the only thing we do is printing this, which doesn't add much to the debug messages already emitted.

431

If we cannot tail-predicate, does that mean we keep checking TPValidity here? I think this is place where the usage of CannotTailPredicate and TailPredicate can be a bit confusing.

560

Nit, just: bool IsDo = Start->getOpcode() == ARM::t2DoLoopStart;

llvm/test/CodeGen/Thumb2/LowOverheadLoops/vector-arith-codegen.ll
392

If I'm not mistaken, function @vector_mul_vector_u8 and @vector_mul_vector_s8 above are exactly the same?

519

Same with this and the function above?

samparker marked 3 inline comments as done.Nov 13 2019, 3:13 AM
samparker added inline comments.
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
48

We need to track whether we've found only one vctp instruction, so I need some flag. But yes, a rename sounds good.

431

I'll rename it to FoundOneVCTP. We'll look for vpr users only once we've found the vctp, but we need to check all the instructions in the loop so that we catch any of our unsupported vector instructions.

llvm/test/CodeGen/Thumb2/LowOverheadLoops/vector-arith-codegen.ll
392

Ah yes, because there's no extending going on. I'll remove the duplicates.

samparker updated this revision to Diff 229055.Nov 13 2019, 3:37 AM
  • Renamed VPTMIs and fixed typos.
  • Renamed TailPredicate and added a method for IsTailPredicationLegal to make the code more readable.
  • Added early exits.
  • Removed tests.
SjoerdMeijer accepted this revision.Nov 13 2019, 5:51 AM

Thanks, this looks good to me.

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
74

I am so happy with this change, because this confused me but now it all makes sense again ! :-)

This revision is now accepted and ready to land.Nov 13 2019, 5:51 AM
This revision was automatically updated to reflect the committed changes.