[PATCH] D109130: [GlobalISel] Combine icmp eq/ne x, 0/1 -> x when x == 0 or 1
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 1 22:03:00 PDT 2021
paquette created this revision.
paquette added reviewers: aemerson, arsenm, jroelofs.
Herald added subscribers: hiraditya, kristof.beyls, rovka.
paquette requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
This adds the following combines:
x = ... 0 or 1
c = icmp eq x, 1
->
c = x
and
x = ... 0 or 1
c = icmp ne x, 0
->
c = x
When the target's true value for the relevant types is 1.
This showed up in the following situation:
https://godbolt.org/z/M5jKexWTW
SDAG currently supports the `ne` case, but not the `eq` case. This can probably be further generalized, but I don't feel like thinking that hard right now.
This gives some minor code size improvements across the board on CTMark at -Os for AArch64. (0.1% for 7zip and pairlocalalign in particular.)
https://reviews.llvm.org/D109130
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/combine-icmp-to-lhs-known-bits.mir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109130.370158.patch
Type: text/x-patch
Size: 11450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210902/0effa3f1/attachment.bin>
More information about the llvm-commits
mailing list