This is an archive of the discontinued LLVM Phabricator instance.

[NFC][InstCombine] Add baseline tests for canonicalizing "and, add", "or, add", "xor, add"
ClosedPublic

Authored by emgullufsen on Aug 3 2022, 9:56 PM.

Details

Summary

Baseline tests for canonicalizing "logic op, add"

((x + C1) & C2) --> ((x & C2) + C1)     
((x + C1) ^ C2) --> ((x ^ C2) + C1)     
((x + C1) | C2) --> ((x | C2) + C1)

for suitable constants C1 and C2.

Diff Detail

Event Timeline

emgullufsen created this revision.Aug 3 2022, 9:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 9:56 PM
emgullufsen requested review of this revision.Aug 3 2022, 9:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 9:56 PM
emgullufsen retitled this revision from [NFC][InstCombine] Add baseline tests for canonicalizing ((x + C1) & C2) --> ((x & C2) + C1) ((x + C1) ^ C2) --> ((x ^ C2) + C1) ((x + C1) | C2) --> ((x | C2) + C1) for suitable constants C1 and C2. to [NFC][InstCombine] Add baseline tests for canonicalizing "and, add", "or, add", "xor, add".Aug 3 2022, 10:41 PM
emgullufsen edited the summary of this revision. (Show Details)

I need a few more test cases I'd neglected (multiple use negative case at least) I am realizing, will update patch.

Added multiple use negative tests

RKSimon edited the summary of this revision. (Show Details)Aug 9 2022, 6:26 AM

vector test coverage?

Added vector tests

foad added a comment.Aug 23 2022, 6:54 AM

Looks fine but please just check the comments.

llvm/test/Transforms/InstCombine/and-xor-or.ll
4378

112 is not 0xFF800000

Address comments (bad hex values in comments for 112 and 15)

emgullufsen marked an inline comment as done.Aug 24 2022, 8:36 AM
spatel accepted this revision.Aug 26 2022, 9:23 AM

LGTM

This revision is now accepted and ready to land.Aug 26 2022, 9:23 AM
This revision was landed with ongoing or failed builds.Aug 26 2022, 10:57 AM
This revision was automatically updated to reflect the committed changes.