[PATCH] D135633: [GlobalISel] Combine things like (z = x <= 0 ? z = x : z = 0) -> x & (x >> bw-1)
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 10 18:25:37 PDT 2022
paquette created this revision.
paquette added reviewers: aemerson, arsenm.
Herald added subscribers: hiraditya, kristof.beyls, rovka.
Herald added a project: All.
paquette requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
If we have a signed comparison like this:
%cmp = icmp sge i32 %x, 0
%select = select i1 %cmp, i32 %x, i32 0
ret i32 %select
We can represent it using an `and` + a right shift.
On AArch64, this allows us to do the cmp + select in a single instruction.
This also works with signed less-than operators, but instead we compliment the
shift first.
Saves 0.12% code size on CTMark/lencod @ -Os for AArch64. Other minor code size
savings as well with no regressions.
https://godbolt.org/z/7E4vYWah6
https://reviews.llvm.org/D135633
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/lib/Target/AArch64/AArch64ISelLowering.h
llvm/test/CodeGen/AArch64/combine-select-to-and-shift.mir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135633.466676.patch
Type: text/x-patch
Size: 14523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221011/1c05680c/attachment.bin>
More information about the llvm-commits
mailing list