[PATCH] D149699: [InstCombine] Improve bswap optimization
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 4 08:56:24 PDT 2023
goldstein.w.n added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:1296
+ }
+ }
+ return nullptr;
----------------
In that case that both X and Y match the intrinsic, we should still do the optimization even if X/Y have multi-use.
I.e
```
declare i16 @llvm.bswap.i16(i16)
declare void @use.i16(i16)
define i16 @bs_and_lhs_bs16(i16 %x, i16 %y) {
%bx = tail call i16 @llvm.bswap.i16(i16 %x)
%by = tail call i16 @llvm.bswap.i16(i16 %y)
%r = and i16 %bx, %by
%br = tail call i16 @llvm.bswap.i16(i16 %r)
call void @use.i16(i16 %bx)
call void @use.i16(i16 %by)
ret i16 %br
}
```
Should become:
```
declare i16 @llvm.bswap.i16(i16)
declare void @use.i16(i16)
define i16 @bs_and_lhs_bs16(i16 %x, i16 %y) {
%bx = tail call i16 @llvm.bswap.i16(i16 %x)
%by = tail call i16 @llvm.bswap.i16(i16 %y)
%r = and i16 %x, %y
call void @use.i16(i16 %bx)
call void @use.i16(i16 %by)
ret i16 %r
}
```
I think an initiali if statement that check for that case would work.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149699/new/
https://reviews.llvm.org/D149699
More information about the llvm-commits
mailing list