This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Factor out a common pattern match used 3 times. NFC.
ClosedPublic

Authored by rampitec on Dec 22 2021, 4:10 PM.

Details

Summary

This is needed for the next patch which will add more patterns
to the same match.

Diff Detail

Event Timeline

rampitec created this revision.Dec 22 2021, 4:10 PM
rampitec requested review of this revision.Dec 22 2021, 4:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2021, 4:10 PM

Making the caller pass a dummy seems awkward.
I don't have any suggestions to improve it, but adding some more potential reviewers.

Making the caller pass a dummy seems awkward.
I don't have any suggestions to improve it, but adding some more potential reviewers.

I can pass a pointer with default null. Is that better?

spatel accepted this revision.Jan 6 2022, 9:00 AM

Making the caller pass a dummy seems awkward.
I don't have any suggestions to improve it, but adding some more potential reviewers.

I can pass a pointer with default null. Is that better?

Wouldn't it be a pointer to a pointer in that case?
Since we already have 'X' in the caller, we could just always pass 'X' instead of using 'Dummy' even if it is not used.
I don't have a strong opinion on it, so LGTM.
Although I am still hoping we can find an alternative to complicated (yet ultimately still fragile) pattern-matching that is trying to work around limits of reassociation and multi-use.

This revision is now accepted and ready to land.Jan 6 2022, 9:00 AM

Making the caller pass a dummy seems awkward.
I don't have any suggestions to improve it, but adding some more potential reviewers.

I can pass a pointer with default null. Is that better?

Wouldn't it be a pointer to a pointer in that case?

Yes

Since we already have 'X' in the caller, we could just always pass 'X' instead of using 'Dummy' even if it is not used.

This will clobber X even if pattern is not matched, and then X is used later at line 1800.

I don't have a strong opinion on it, so LGTM.
Although I am still hoping we can find an alternative to complicated (yet ultimately still fragile) pattern-matching that is trying to work around limits of reassociation and multi-use.

I hope D114126 is a right answer to multi-use problem, although somewhat complex.

This revision was landed with ongoing or failed builds.Jan 6 2022, 10:24 AM
This revision was automatically updated to reflect the committed changes.