This is an archive of the discontinued LLVM Phabricator instance.

[globalisel][legalizerinfo] Introduce dedicated extending loads and add lowerings for them
ClosedPublic

Authored by dsanders on Apr 11 2018, 3:47 PM.

Details

Summary

Previously, a extending load was represented at (G_*EXT (G_LOAD x)).
This had a few drawbacks:

  • G_LOAD had to be legal for all sizes you could extend from, even if registers didn't naturally hold those sizes.
  • All sizes you could extend from had to be allocatable just in case the extend went missing (e.g. by optimization).
  • At minimum, G_*EXT and G_TRUNC had to be legal for these sizes. As we improve optimization of extends and truncates, this legality requirement would spread without considerable care w.r.t when certain combines were permitted.
  • The SelectionDAG importer required some ugly and fragile pattern rewriting to translate patterns into this style.

This patch begins changing the representation to:

  • (G_[SZ]EXTLOAD x)
  • (G_LOAD x) any-extends when MMO.getSize() * 8 < ResultTy.getSizeInBits()

which resolves these issues by allowing targets to work entirely in their
native register sizes, and by having a more direct translation from
SelectionDAG patterns.

This patch introduces the new generic instructions and new variation on
G_LOAD and adds lowering for them to convert back to the existing
representations.

Depends on D45466

Diff Detail

Event Timeline

dsanders created this revision.Apr 11 2018, 3:47 PM
aemerson accepted this revision.Apr 18 2018, 5:30 PM
aemerson added a subscriber: aemerson.

LGTM, with addition of -verify-machineinstrs to the tests.

lib/CodeGen/GlobalISel/LegalizerHelper.cpp
742

LLVM_FALLTHROUGH here

This revision is now accepted and ready to land.Apr 18 2018, 5:30 PM

Thanks. I'll commit this (with the nits fixed) when I'm back in the office on Thursday

This revision was automatically updated to reflect the committed changes.