This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Make MatchBSwap also match bit reversals
ClosedPublic

Authored by jmolloy on Dec 1 2015, 9:07 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 41523.Dec 1 2015, 9:07 AM
jmolloy retitled this revision from to [InstCombine] Make MatchBSwap also match bit reversals.
jmolloy updated this object.
jmolloy added reviewers: majnemer, hfinkel.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
majnemer edited edge metadata.Dec 2 2015, 8:04 AM

Do you have data on how this change impacts compile time?

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
20

Please sort this include.

jmolloy updated this revision to Diff 41641.Dec 2 2015, 9:18 AM
jmolloy edited edge metadata.

Hi David,

Include order updated (StringExtras was only needed for debugging).

As I mentioned on the list, but it doesn't appear to have made its way here to phab, there was no measurable compile time difference with this patch on a clang bootstrap.

James

Hi David,

Ping!

James

Hi James,

I had a look over this and the logic seems sound to me. I only have one (superficial) complaint: the old commets in CollectBSwapBitReverseParts refer only about bswap. Maybe we can rename it to something like CollectBitParts (since we're basically only tracking bits now and have the bswap/bitreverse validation somewhere else).

Cheers,
Silviu

sbaranga accepted this revision.Dec 10 2015, 7:14 AM
sbaranga added a reviewer: sbaranga.

LGTM with the comment fixes.

This revision is now accepted and ready to land.Dec 10 2015, 7:14 AM
jmolloy closed this revision.Dec 12 2015, 5:35 AM

r255334.