The implementation of D149577
The patch implements a helper function that matches and fold the following cases in the InstCombine pass:
- bswap(logic_op(x, bswap(y))) -> logic_op(bswap(x), y)
- bswap(logic_op(bswap(x), y)) -> logic_op(x, bswap(y))
- bswap(logic_op(bswap(x), bswap(y))) -> logic_op(x, y) in multiuse case, which still reduces the number of instructions.
The helper function accepts bswap and bitreverse intrinsics. This patch folds the bswap cases and remain the bitreverse optimization for the future
"bswap/bitreverse" -> "bswap"