[InstCombine] Make MatchBSwap also match bit reversals
commite15387964886dcb3d919648218da958f9707d988
authorJames Molloy <james.molloy@arm.com>
Fri, 11 Dec 2015 10:04:51 +0000 (11 10:04 +0000)
committerJames Molloy <james.molloy@arm.com>
Fri, 11 Dec 2015 10:04:51 +0000 (11 10:04 +0000)
treec2dab2e9c31086e69909ee97613a8475b19446de
parent11663248fea4f05ded465b0d7c03c8bfb2772af8
[InstCombine] Make MatchBSwap also match bit reversals

MatchBSwap has most of the functionality to match bit reversals already. If we switch it from looking at bytes to individual bits and remove a few early exits, we can extend the main recursive function to match any sequence of ORs, ANDs and shifts that assemble a value from different parts of another, base value. Once we have this bit->bit mapping, we can very simply detect if it is appropriate for a bswap or bitreverse.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255334 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
lib/Transforms/InstCombine/InstCombineInternal.h
test/Transforms/InstCombine/bitreverse-recognize.ll [new file with mode: 0644]