[PATCH] D108773: [AArch64][GlobalISel] Optimize G_BUILD_VECTOR of undef + 1 elt -> SUBREG_TO_REG

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 26 11:13:41 PDT 2021


paquette created this revision.
paquette added reviewers: aemerson, jroelofs.
Herald added subscribers: hiraditya, kristof.beyls, rovka.
paquette requested review of this revision.
Herald added a project: LLVM.

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.


https://reviews.llvm.org/D108773

Files:
  llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/select-build-vector.mir
  llvm/test/CodeGen/AArch64/arm64-rev.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108773.368937.patch
Type: text/x-patch
Size: 5942 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210826/ce577159/attachment.bin>


More information about the llvm-commits mailing list