[PATCH] D93411: [GlobalISel] Transform sext (cmp pred, x, y) -> select (cmp pred, x, y) tval, 0

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 16 11:01:23 PST 2020


paquette created this revision.
paquette added reviewers: aemerson, arsenm.
Herald added subscribers: steven.zhang, hiraditya, kristof.beyls, rovka.
paquette requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

On some targets, such as AArch64, it's possible to optimize G_ICMP + G_SELECT pairs more effectively than G_ICMP + G_SEXT pairs.

Example: https://godbolt.org/z/5nd3Gf

This is a combine that already exists in the DAGCombiner (see `DAGCombiner::visitSIGN_EXTEND`).

Like the DAGCombiner, this uses a target hook (`convertSelectOfConstantsToMath`) to allow targets to choose whether they want this, or combines that change selects into extends.

For AArch64, this is a minor code size win on CTMark at -Os.


https://reviews.llvm.org/D93411

Files:
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/Target/GlobalISel/Combine.td
  llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/prelegalizer-combiner-sext-to-select.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93411.312263.patch
Type: text/x-patch
Size: 8884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201216/38746235/attachment.bin>


More information about the llvm-commits mailing list