diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2023-02-06 12:05:10 -0600 |
---|---|---|
committer | Noah Goldstein <goldstein.w.n@gmail.com> | 2023-02-06 14:09:17 -0600 |
commit | 725b72c1fa608c886a1a5dbb75df23a05e91d5e8 (patch) | |
tree | f525080f1fb1d26f27f0a2bccc295fb9d1e367ed /llvm/lib/CodeGen/BranchFolding.cpp | |
parent | 3857d9decc4db2a0f14fd7cb7cd69be55f12cc4a (diff) | |
download | llvm-725b72c1fa608c886a1a5dbb75df23a05e91d5e8.zip llvm-725b72c1fa608c886a1a5dbb75df23a05e91d5e8.tar.gz llvm-725b72c1fa608c886a1a5dbb75df23a05e91d5e8.tar.bz2 |
Only match BMI (BLSR, BLSI, BLSMSK) if the add/sub op is single use
If the add/sub is not single use, it will need to be materialized
later, in which case using the BMI instruction is a de-optimization in
terms of code-size and throughput.
i.e:
```
// Good
leal -1(%rdi), %eax
andl %eax, %eax
xorl %eax, %esi
...
```
```
// Unecessary BMI (lower throughput, larger code size)
leal -1(%rdi), %eax
blsr %edi, %eax
xorl %eax, %esi
...
```
Note, this may cause more `mov` instructions to be emitted sometimes
because BMI instructions only have 1 src and write-only to dst. A
better approach may be to only avoid BMI for (and/xor X, (add/sub
0/-1, X)) if this is the last use of X but NOT the last use of
(add/sub 0/-1, X).
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D141180
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
0 files changed, 0 insertions, 0 deletions