[PATCH] D88578: [InstCombine] recognizeBSwapOrBitReverseIdiom - support for 'partial' bswap patterns (PR47191)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 10:26:02 PDT 2020
spatel added inline comments.
================
Comment at: llvm/test/Transforms/InstCombine/bswap.ll:382
+; CHECK-NEXT: [[TMP6:%.*]] = or i64 [[TMP3]], [[TMP5]]
+; CHECK-NEXT: ret i64 [[TMP6]]
;
----------------
RKSimon wrote:
> We would have reduced this to bswap+mask but InstCombinerImpl::matchBSwap is too harsh at filtering out or(A,B) patterns where A and B have different opcodes.
Add test(s) that already have a partial bswap, so we can see the most basic transform enabled by this patch?
Something like this:
```
define i32 @partial_bswap(i32 %x) {
%x3 = shl i32 %x, 24
%a2 = shl i32 %x, 8
%x2 = and i32 %a2, 16711680
%x32 = or i32 %x3, %x2
%t1 = and i32 %x, -65536
%t2 = call i32 @llvm.bswap.i32(i32 %t1)
%r = or i32 %x32, %t2
ret i32 %r
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88578/new/
https://reviews.llvm.org/D88578
More information about the llvm-commits
mailing list