[PATCH] D84550: [AArch64][GlobalISe] Fold G_AND and G_LSHR into ubfm

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 13:03:19 PDT 2020


paquette created this revision.
paquette added a reviewer: aemerson.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.

This partially implements `isBitfieldExtractOpFromAnd` from AArch64ISelDAGtoDAG.

It only handles the simplest case. That is,

  %mask = G_CONSTANT
  %constant = G_CONSTANT
  %lshr = G_LSHR %something, %constant
  %dst = G_AND %lshr, %mask

becomes

  %dst = ubfm %something, immr, imms

To separate the matching from selection, and to avoid adding this to `earlySelect`, this is done in the post-legalizer combiner. This adds a target-specific G_UBFM instruction which is selected to UBFMWri or UBFMXri depending on the destination size.

The only thing that bothers me about this approach is that in one of the currently-unimplemented cases AArch64ISelDAGtoDAG sometimes inserts a SUBREG_TO_REG. I'm not sure how we would accomplish the same thing in the combiner right now.


https://reviews.llvm.org/D84550

Files:
  llvm/lib/Target/AArch64/AArch64Combine.td
  llvm/lib/Target/AArch64/AArch64InstrGISel.td
  llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
  llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-combiner-ubfm.mir
  llvm/test/CodeGen/AArch64/GlobalISel/select-ubfm.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84550.280561.patch
Type: text/x-patch
Size: 26013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200724/316540ab/attachment-0001.bin>


More information about the llvm-commits mailing list