[PATCH] D117680: [InstCombine] Fold bswap(shl(x, C)) -> and(x, 255)
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 19 10:45:46 PST 2022
craig.topper added a comment.
In D117680#3255573 <https://reviews.llvm.org/D117680#3255573>, @spatel wrote:
> In D117680#3255184 <https://reviews.llvm.org/D117680#3255184>, @chfast wrote:
>
>> My motivation is rather boring. I have a generic data -> integer loader. The data is in big-endian order. For i32 example the data can be from 1 to 4 bytes in size. Here is the generic template which handles all 4 cases:
>> https://godbolt.org/z/dPcGjvb94
>
> Thanks! I guessed there was more than just this one potential optimization, but that makes it clearer.
> Pushing a logical shift after the bswap (and reversing direction) might get us most of what we need:
> https://alive2.llvm.org/ce/z/2zveR6
> That should allow the existing demanded bits fold to trigger in the simplest cases if I'm seeing it correctly.
That wouldn't help with the (bswap (and)) though would it? But my computeKnownBits suggestion would allow the bswap to be reduced to a shift.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117680/new/
https://reviews.llvm.org/D117680
More information about the llvm-commits
mailing list