This is an archive of the discontinued LLVM Phabricator instance.

[SVE][CodeGen] Add the ExtensionType flag to MGATHER
ClosedPublic

Authored by kmclaughlin on Nov 9 2020, 8:04 AM.

Details

Summary

Adds the ExtensionType flag, which reflects the LoadExtType of a MaskedGatherSDNode.
Also updated SelectionDAGDumper::print_details so that details of the gather
load (is signed, is scaled & extension type) are printed.

Diff Detail

Event Timeline

kmclaughlin created this revision.Nov 9 2020, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2020, 8:04 AM
kmclaughlin requested review of this revision.Nov 9 2020, 8:04 AM
  • Moved changes to SplitVecRes_MGATHER & SplitVecOp_MGATHER into this patch from D91092
kmclaughlin edited the summary of this revision. (Show Details)

Added DAG combines for the following:

  • fold (and (masked_gather x)) -> (zext_masked_gather x)
  • fold (sext_inreg (masked_gather x)) -> (sext_masked_gather x)
sdesmalen added inline comments.Nov 24 2020, 10:53 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
938 ↗(On Diff #304868)

nit: Capitalise to ULL seems more common in LLVM.

955 ↗(On Diff #304868)

nit: unnecessary curly braces.

5665 ↗(On Diff #304868)

I'm surprised this doesn't break anything for other targets like X86.

In any case I think this fold (and same for the sext_masked_gather) should be guarded under TargetLoweringInfo::isVectorLoadExtDesirable, so that the target can inspect the operation and type, to make a suitable decision.

11526 ↗(On Diff #304868)

is !LegalOperations necessary here? The combine for zext_masked_gather doesn't seem to need it.

11527 ↗(On Diff #304868)

Is this missing a N0.hasOneUse() ?

kmclaughlin marked 5 inline comments as done.
  • Replaced calls to TLI.isLoadExtLegal with TLI.isVectorLoadExtDesirable in the masked gather combines, which also checks the type of load operation being used
  • Removed unnecessary !LegalOperations from the zext_masked_gather combine and added a check for hasOneUse(), matching the sext_masked_gather combine

Hi @kmclaughlin, we just discussed this offline, just sharing my thoughts here as well.

The code-changes seem fine, but I think the patch series is in the wrong order. i.e. D91084 is an optimization for D91092. The better order I think would probably be to:

  1. Have https://reviews.llvm.org/D91092 as a standalone patch (you'll need to update the test and remove the reference to MGT->getExtensionType()
  2. Add the ExtensionType flag to MGATHER (re-adding the reference to MGT->getExtensionType() in LowerMGATHER, but the tests are probably unchanged).
  3. Add the DAGCombines to merge zext/sext into the mgather itself (which then requires updating the tests)
kmclaughlin edited the summary of this revision. (Show Details)

Removed isConstantSplatVectorMaskForType() & the DAG combines for s/ext_masked_gather (these will be added in a follow up patch)

Hi @sdesmalen, I've updated the series as suggested and the patches are now in the following order:
D91092 - Lower scalable masked scatters (with references to ExtensionType in LowerMGATHER removed)
D91084 - Add the ExtensionType flag to MGATHER
D92230 - DAG combines for z/sext of a masked gather, adding ExtensionType back into LowerMGATHER

Thanks for reviewing all of these patches!

This revision is now accepted and ready to land.Nov 27 2020, 10:34 AM
This revision was automatically updated to reflect the committed changes.