[PATCH] D90701: [AArch64][GlobalISel] Select CSINC and CSINV for G_SELECT with constants

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 11:23:38 PST 2020


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

Select the following:

- G_SELECT cc, 0, 1 -> CSINC zreg, zreg, cc
- G_SELECT cc 0, -1 -> CSINV zreg, zreg cc
- G_SELECT cc, 1, f -> CSINC f, zreg, inv_cc
- G_SELECT cc, -1, f -> CSINV f, zreg, inv_cc
- G_SELECT cc, t, 1 -> CSINC t, zreg, cc
- G_SELECT cc, t, -1 -> CSINC t, zreg, cc

(IR example: https://godbolt.org/z/YfPna9)

These correspond to a bunch of the AArch64csel patterns in AArch64InstrInfo.td.

Unfortunately, it doesn't seem like we can import patterns that use NZCV like those ones do. E.g.

  def : Pat<(AArch64csel GPR32:$tval, (i32 1), (i32 imm:$cc), NZCV),
          (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>;

So we have to manually select these for now.

This replaces `selectSelectOpc` with an `emitSelect` function, which performs these optimizations.


https://reviews.llvm.org/D90701

Files:
  llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-compare.mir
  llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90701.302638.patch
Type: text/x-patch
Size: 27591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201103/e3a408a7/attachment.bin>


More information about the llvm-commits mailing list