[PATCH] D92860: [AArch64][GlobalISel] Fold binops on the true side of G_SELECT
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 09:51:53 PST 2020
paquette created this revision.
paquette added a reviewer: aemerson.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls, rovka.
paquette requested review of this revision.
Herald added a project: LLVM.
This implements the following folds:
G_SELECT cc, (G_SUB 0, %x), %false -> CSNEG %x, %false, inv_cc
G_SELECT cc, (G_XOR x, -1), %false -> CSINV %x, %false, inv_cc
This is similar to the folds introduced in 5bc0bd05e6a8d788e08cdf3d154f3a33202aee53 <https://reviews.llvm.org/rG5bc0bd05e6a8d788e08cdf3d154f3a33202aee53>.
In 5bc0bd05e6a8d788e08cdf3d154f3a33202aee53 <https://reviews.llvm.org/rG5bc0bd05e6a8d788e08cdf3d154f3a33202aee53> I mentioned that we may prefer to do this in AArch64PostLegalizerLowering.
I think that it's probably better to do this in the selector. The way we select G_SELECT depends on what register banks end up being assigned to it. If we did this in AArch64PostLegalizerLowering, then we'd end up checking *every* G_SELECT to see if it's worth swapping operands. Doing it in the selector allows us to restrict the optimization to only relevant G_SELECTs.
Also fix up some comments in `TryFoldBinOpIntoSelect` which are kind of confusing IMO.
Example IR: https://godbolt.org/z/3qPGca
https://reviews.llvm.org/D92860
Files:
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92860.310255.patch
Type: text/x-patch
Size: 4701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201208/e55c1897/attachment.bin>
More information about the llvm-commits
mailing list