This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold (a | b) ^ (~a | ~b) --> ~(a ^ b) and (a & b) ^ (~a & ~b) --> ~(a ^ b)
ClosedPublic

Authored by craig.topper on Jun 30 2017, 12:37 AM.

Details

Summary

I came across this while thinking about what would happen if one of the operands in this xor pattern was itself a inverted (A & ~B) ^ (~A & B)-> (A^B).

The patterns here assume that the (~a | ~b) will be demorganed to ~(a & b) first. Though I wonder if there's a multiple use case that would prevent the demorgan.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 30 2017, 12:37 AM
spatel accepted this revision.Jul 1 2017, 6:40 AM

LGTM.

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