[InstCombine] Simplify bswap -> shift
authorPawe Bylica <chfast@gmail.com>
Thu, 20 Jan 2022 23:56:38 +0000 (00:56 +0100)
committerPaweł Bylica <chfast@gmail.com>
Fri, 21 Jan 2022 00:25:30 +0000 (01:25 +0100)
commit1d7604fdcebda9cc431b7f19c2f4cb769efdca02
treeb9fb5eb8dbd4c5060350dd7625b5c9318d7d0124
parent37e0c58559ad367f16960fd65c8efb7bb1a6414f
[InstCombine] Simplify bswap -> shift

Simplify bswap(x) to shl(x) or lshr(x) if x has exactly one
"active byte", i.e. all active bits are contained in boundaries
of a single byte of x.

https://alive2.llvm.org/ce/z/nvbbU5
https://alive2.llvm.org/ce/z/KiiL3J

Reviewed By: spatel, craig.topper, lebedev.ri

Differential Revision: https://reviews.llvm.org/D117680
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/bswap-fold.ll