This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Add single use checks to SimplifyBSwap to ensure we are really saving instructions
ClosedPublic

Authored by craig.topper on Jul 3 2017, 11:44 PM.

Details

Summary

Bswap isn't a simple operation so we need to make sure we are really removing a call to it before doing these simplifications.

For the case when both LHS and RHS are bswaps I've allowed it to be moved if either LHS or RHS has a single use since that at least allows us to move it later where it might find another bswap to combine with and it decreases the use count on the other side so maybe the other user can be optimized.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jul 3 2017, 11:44 PM
spatel accepted this revision.Jul 6 2017, 6:16 AM

LGTM. See inline for an NFC pre- or post-commit cleanup.

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
78–81 ↗(On Diff #105139)

It's independent of this patch, but this comment is too specific for this function because it doesn't mention the pattern with a constant operand. I'd make the comment more general and/or remove it. The function name could also mention 'bitwise op' since that is a requirement for any transform in this function.

This revision is now accepted and ready to land.Jul 6 2017, 6:16 AM
This revision was automatically updated to reflect the committed changes.