[all-commits] [llvm/llvm-project] cd9a52: [AArch64][GlobalISel] Fold binops on the true side...
Jessica Paquette via All-commits
all-commits at lists.llvm.org
Tue Dec 8 10:48:57 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: cd9a52b99e685e8a77dd85d25c7d1ec8b86b9f55
https://github.com/llvm/llvm-project/commit/cd9a52b99e685e8a77dd85d25c7d1ec8b86b9f55
Author: Jessica Paquette <jpaquette at apple.com>
Date: 2020-12-08 (Tue, 08 Dec 2020)
Changed paths:
M llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
M llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
Log Message:
-----------
[AArch64][GlobalISel] Fold binops on the true side of G_SELECT
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.
In 5bc0bd05e6a8d788e08cdf3d154f3a33202aee53 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
Differential Revision: https://reviews.llvm.org/D92860
More information about the All-commits
mailing list