This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold (!iszero(A & K1) & !iszero(A & K2)) -> (A & (K1 | K2)) == (K1 | K2) if K1 and K2 are a 1-bit mask
ClosedPublic

Authored by craig.topper on Jun 15 2017, 11:30 AM.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 15 2017, 11:30 AM
spatel edited edge metadata.Jun 15 2017, 11:36 AM

Nice! I was wondering if that was missing.

Can you make a helper function to avoid the code duplication?
Add the tests as a pre-commit, so we just get the diffs?

Will do.

Can I change foldOrOfIcmps to take CxtI by reference so we discourage anyone from passing nullptr.

Will do.

Can I change foldOrOfIcmps to take CxtI by reference so we discourage anyone from passing nullptr.

I have no objections. I'd go full-strength and fix all of the params to be refs in all of the related functions, so everything is uniform. :)
I'd really like to refactor (And/Or)OfICmps, so we have the deMorgan'd versions of each fold together or adjacent. That way, we'll more easily know what's missing from either side.

Move to helper method. Make test diffs relative.

spatel accepted this revision.Jun 15 2017, 3:56 PM

LGTM.

This revision is now accepted and ready to land.Jun 15 2017, 3:56 PM
This revision was automatically updated to reflect the committed changes.