This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Add MVE beats vector cost model
ClosedPublic

Authored by dmgreen on Aug 9 2019, 4:50 AM.

Details

Summary

The MVE architecture has the idea of "beats", where a vector instruction can be executed over several ticks of the architecture. This adds a similar system into the Arm backend cost model, multiplying the cost of all vector instructions by a factor.

This factor essentially becoming the expected difference between scalar code and vector code, on average. MVE Vector instructions can also overlap so the a true cost of them is often lower. Equally scalar instructions can in some situations be dual issued, or have other optimisations or more efficient instructions. The default is chosen as 2. This should not prevent vectorisation is a most cases (as the vector instructions will still be doing at least 4 times the work), but it will help prevent over vectorising in cases where the benefits are less likely.

This adds things so far to the obvious places in ARMTargetTransformInfo, and updates a few related costs like not treating float instructions as cost 2 just because they are floats.

Diff Detail

Repository
rL LLVM

Event Timeline

dmgreen created this revision.Aug 9 2019, 4:50 AM
samparker added inline comments.Aug 9 2019, 5:34 AM
llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
396 ↗(On Diff #214339)

What part of the architecture suggests that we should avoid mixing scalar and vector?

dmgreen added inline comments.Aug 9 2019, 10:17 AM
llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
396 ↗(On Diff #214339)

The idea was to stop all the vmov's into and out of gpr registers. For floats it would be better than that, as they are already in the correct registers (I had a check for that but took it out for some reason).

This was also to try and stop cases where we vectorise, just to end up serialising the result. It would be better to use scalar and not loose out on things like parallel dsp or unrolling, just for to use a vector load and store.

samparker accepted this revision.Aug 12 2019, 2:24 AM

LGTM

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
396 ↗(On Diff #214339)

Ok, maybe add this to the comment?

This revision is now accepted and ready to land.Aug 12 2019, 2:24 AM
This revision was automatically updated to reflect the committed changes.