[PATCH] D99908: [GlobalISel] Simplify G_ICMP against true/false when boolean contents are 0/1

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 5 17:02:48 PDT 2021


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

Assuming 0 == false and 1 == true, if we have one of

  %c = G_ICMP eq %x, 1
  %c = G_ICMP ne %x, 0

If we know `%x` is either 0 or 1, we can replace `%c` with `%x`.

For AArch64, this saves 0.1% text size on CTMark/7zip and CTMark/mafft/pairlocalalign at -Os, and gives minor code size improvements across the rest of CTMark as well.


https://reviews.llvm.org/D99908

Files:
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/Target/GlobalISel/Combine.td
  llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-simplify-cmp-known-true-false.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99908.335355.patch
Type: text/x-patch
Size: 11906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210406/f70273a3/attachment.bin>


More information about the llvm-commits mailing list