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
Instead of making this a member function. Can you leave it static. To create new instructions you can add an extra argument InstCombiner::BuilderTy &Builder.
It should look like: InstCombineAndOrXor.cc::reassociateFCmps