This is an archive of the discontinued LLVM Phabricator instance.

[WIP][AArch64] Add support for matching RBIT, REV/REV64, REV32, and REV16 during ISelLowering.
AbandonedPublic

Authored by mcrosier on May 25 2016, 9:00 AM.

Details

Reviewers
jmolloy
Summary

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

Diff Detail

Event Timeline

mcrosier updated this revision to Diff 58432.May 25 2016, 9:00 AM
mcrosier retitled this revision from to [WIP][AArch64] Add support for matching RBIT, REV/REV64, REV32, and REV16 during ISelLowering..
mcrosier updated this object.
mcrosier added a reviewer: jmolloy.

Perhaps we could also reuse the code in instcombine and generate target-specific intrinsics..

jmolloy edited edge metadata.May 26 2016, 2:56 AM

Hi Chad,

I prefer your idea of folding this into the current InstCombine code and having InstCombine produce target intrinsics. InstCombine already does this for SSE intrinsics, so I don't see why it couldn't produce ARM/AArch64 intrinsics.

This would also naturally make this work for ARM, not just AArch64, and you'd also get the ZExt support you're adding in D20591, not to mention reducing code duplication and compile time.

Cheers,

James

mcrosier abandoned this revision.May 26 2016, 6:32 AM

SGTM! Thanks, James.