Hi James,
This patch is a port of r257875: [InstCombine] Rewrite bswap/bitreverse handling completely.
However, unlike the implementation in InstCombine this can handle matching the target-specific instructions REV16 and REV32. It may also catch additional cases exposed during isel lowering.
Note:
For an i32 I don't think we'll ever see a REV16 because that's equivalent to a ROR #16.
Similarly, for an i64 I don't think we'll ever see a REV32 because that's equivalent to a ROR #32.
I didn't complete the codegen part, but I did run SPEC2000, SPEC2006, and llvm-test-suite with the assertions to see what cases we encounter.
Across all of those tests I saw one RBIT in the llvm-test-suite and no other hits. We may be able to do more interesting things, like match like match a REV16 on the low-half of an i64, but I'm not sure if pursing this further is interesting.
Finishing out the work is trivial, but what are your thoughts? Would it be worth the compile-time?
Chad