This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner][SVE] Add support for illegal extending masked loads
ClosedPublic

Authored by david-arm on Aug 30 2023, 6:02 AM.

Details

Summary

In some cases where the same mask is used for multiple
extending masked loads it can be more efficient to combine
the zero- or sign-extend into the load even if it's not a
legal or custom operation. This leads to splitting up the
extending load into smaller parts, which also requires
splitting the mask. For SVE at least this improves the
performance of the SPEC benchmark x264 slightly on
neoverse-v1 (~0.3%), and at least one other benchmark
improves by around 30%. The uplift for SVE seems due to
removing the dependencies (vector unpacks) introduced
between the loads and the vector operations, since this
should increase the level of parallelism.

See tests:

CodeGen/AArch64/sve-masked-ldst-sext.ll
CodeGen/AArch64/sve-masked-ldst-zext.ll

Diff Detail

Event Timeline

david-arm created this revision.Aug 30 2023, 6:02 AM
david-arm requested review of this revision.Aug 30 2023, 6:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2023, 6:02 AM
Matt added a subscriber: Matt.Aug 30 2023, 11:15 AM
david-arm updated this revision to Diff 555339.Sep 1 2023, 5:12 AM
  • Rebase.

Is there value in adding a single fixed length test?

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
5353

Is this strictly necessary? Perhaps it is but I'm wondering if you're really just trying to limit this combine to cases where ExtVT is bigger than legal?

5356

Up to you but personally I think a straight forward:

if (isa<MaskedLoadSDNode>(U))
  ++NumExtMaskedLoads;

is cleaner.

5363

I think this check probably want to be first so that we only start processing ExtVal when we know extending loads are a possibility.

david-arm updated this revision to Diff 555368.Sep 1 2023, 7:30 AM
  • Refactored code according to review comments.
  • Disabled the combine for fixed-width because the code quality doesn't look great.
david-arm marked 3 inline comments as done.Sep 1 2023, 7:32 AM
david-arm added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
5353

Now that I'm disabling this for fixed-width I'd prefer to keep the isLoadExtLegalOrCustom check in order to mirror what the DAGCombiner checks for. That way I hopefully avoid any regressions where I return false for fixed-width.

paulwalker-arm accepted this revision.Sep 1 2023, 8:07 AM
This revision is now accepted and ready to land.Sep 1 2023, 8:07 AM
david-arm closed this revision.Sep 5 2023, 3:52 AM
david-arm marked an inline comment as done.