This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Handle (iszero(A & K1) | iszero(A & K2)) -> (A & (K1 | K2)) != (K1 | K2) when the one of the Ands is commuted relative to the other
ClosedPublic

Authored by craig.topper on Jun 14 2017, 6:13 PM.

Details

Summary

Currently we expect A to be on the same side in both Ands but nothing guarantees that.

While there also switch to using matchers for some of the code.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 14 2017, 6:13 PM
spatel accepted this revision.Jun 15 2017, 10:31 AM

LGTM. See inline for a possible follow-up and nit.

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
1599–1603

Could turn this into a matcher too; using m_Zero() would work with vectors.

test/Transforms/InstCombine/onehot_merge.ll
49

Remove the label to minimize?

This revision is now accepted and ready to land.Jun 15 2017, 10:31 AM
spatel added inline comments.Jun 15 2017, 10:33 AM
test/Transforms/InstCombine/onehot_merge.ll
37

Remove the TODO.

This revision was automatically updated to reflect the committed changes.