[InstCombine] allow variable shift amount in bswap + shift fold
authorSanjay Patel <spatel@rotateright.com>
Wed, 18 May 2022 18:34:48 +0000 (14:34 -0400)
committerSanjay Patel <spatel@rotateright.com>
Wed, 18 May 2022 18:38:16 +0000 (14:38 -0400)
commitebbc37391f9d1de5e8c4bee14493fce20f9c6906
treecfef1573a6645fa162987bc47d149a1aff573f08
parenta3b30d22da173446d1a2ccd49e442b3900b0027c
[InstCombine] allow variable shift amount in bswap + shift fold

When shifting by a byte-multiple:
bswap (shl X, Y) --> lshr (bswap X), Y
bswap (lshr X, Y) --> shl (bswap X), Y

This was limited to constants as a first step in D122010 / 60820e53ec9d3be02 ,
but issue #55327 shows a source example (and there's a test based on that here)
where a variable shift amount is used in this pattern.
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/bswap-fold.ll