This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Optimize G_BUILD_VECTOR of undef + 1 elt -> SUBREG_TO_REG
ClosedPublic

Authored by paquette on Aug 26 2021, 11:13 AM.

Details

Summary

This pattern

%elt = ... something ...
%undef = G_IMPLICIT_DEF
%vec = G_BUILD_VECTOR %elt, %undef, %undef, ... %undef

Can be selected to a SUBREG_TO_REG, assuming %elt and %vec have the same register bank. We don't care about any of the bits in %vec aside from those in %elt, which just happens to be the 0th element.

This is preferable to emitting mov instructions for every index.

This gives minor code size improvements on the test suite at -Os.

Diff Detail

Event Timeline

paquette created this revision.Aug 26 2021, 11:13 AM
paquette requested review of this revision.Aug 26 2021, 11:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2021, 11:13 AM
aemerson accepted this revision.Aug 26 2021, 11:18 AM
This revision is now accepted and ready to land.Aug 26 2021, 11:18 AM