The byte-swap recognizer can now notice that this
uint32_t bswap(uint32_t x) { x = (x & 0x0000FFFF) << 16 | (x & 0xFFFF0000) >> 16; x = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8; return x; }
is a bswap. Fixes PR23863.
Differential D12637
[InstCombine] Recognize another bswap idiom. • chatur01 on Sep 4 2015, 9:09 AM. Authored by
Details The byte-swap recognizer can now notice that this uint32_t bswap(uint32_t x) { x = (x & 0x0000FFFF) << 16 | (x & 0xFFFF0000) >> 16; x = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8; return x; } is a bswap. Fixes PR23863.
Diff Detail Event TimelineComment Actions I'm assuming that the bswap builtin will be triggered in different ways for different target, but that's not what the test here is trying to do, right? Are there tests to make sure that this builtin expands to the correct instructions in the different types of ARM architectures? If not, I'd add that, too.
Comment Actions Hi Renato! Thanks for looking at my patch.
I thought my transformation was target-independent at this level.
There's certainly some, I don't think they're exhaustive of all possibilities. I'll add the test I have to ARM tests at least, but I'll have to do a more intensive sweep of the current tests to make sure they're covering all the possibilities. Sorry for the oversight, this review will have to stall until I've completed that task. Thanks again Renato.
Comment Actions Add tests for ARM backend lowering of the BSWAP instrinsic. The testing coverage in the backend is better now, is this OK to commit? Comment Actions I'm confused as to why this needs any target specific tests. This is a change to IR canonicalization. Comment Actions
I was confused about that too, but I was attempting to address this review comment:
Hopefully I won't be asked to go through the other backends as well now! :) Comment Actions In my experience Backends are expected to do intelligent things with llvm.bswap, I don't think the burden is on you to make sure they aren't doing the wrong thing. Comment Actions I didn't mean you should create the tests, I was just asking if there were tests elsewhere about the intrinsic to instructions conversion. Not that it'd hurt to have the extra tests... Comment Actions OK, sorry for the misunderstanding. Can I commit my original revision, and land the extra backend tests as part of a separate review? Comment Actions Roll back to previous revision. I'll add the extra backend tests |
You don't seem to have added tests for the AND case.