This is an archive of the discontinued LLVM Phabricator instance.

[Instcombine] Canonicalize ~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
ClosedPublic

Authored by bcl5980 on Dec 5 2022, 12:14 AM.

Diff Detail

Event Timeline

bcl5980 created this revision.Dec 5 2022, 12:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 12:15 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
bcl5980 requested review of this revision.Dec 5 2022, 12:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 12:15 AM
bcl5980 updated this revision to Diff 480121.Dec 5 2022, 8:39 AM
bcl5980 retitled this revision from [Instcombine] Canonicalize ~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?) to [Instcombine] Canonicalize xor to or for two logical-select case.
bcl5980 edited the summary of this revision. (Show Details)
spatel added inline comments.Dec 6 2022, 11:21 AM
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
3480

I see that the first match is shared, but this function name and description are not accurate if we add the new fold inside here.

It would be better to create/rename this function as foldNotXor() that has the first match, then it calls or includes sinkNotIntoXor() and includes the new code.

Was there a problem with D139300? That is the same transform as this, but coded differently, right? I find that version easier to read even if it repeats the match for ~xor.

Was there a problem with D139300? That is the same transform as this, but coded differently, right? I find that version easier to read even if it repeats the match for ~xor.

The original idea is this patch do
~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)

D139300 do
~(A & B) ^ (A | ?) -> (A & B) | ~(A | ?)

Then I find this patch can cover D139300, so I abandon D139300.

bcl5980 updated this revision to Diff 480728.Dec 6 2022, 6:17 PM
bcl5980 retitled this revision from [Instcombine] Canonicalize xor to or for two logical-select case to [Instcombine] Canonicalize ~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?).
bcl5980 edited the summary of this revision. (Show Details)
spatel accepted this revision.Dec 7 2022, 6:22 AM

LGTM

This revision is now accepted and ready to land.Dec 7 2022, 6:22 AM
This revision was landed with ongoing or failed builds.Dec 7 2022, 7:52 AM
This revision was automatically updated to reflect the committed changes.