This is an archive of the discontinued LLVM Phabricator instance.

[NFC][NARY-REASSOCIATE] Restructure code to aviod isPotentiallyReassociatable
ClosedPublic

Authored by ebrevnov on Sep 25 2020, 1:53 AM.

Details

Summary

Currently we have to duplicate the same checks in isPotentiallyReassociatable and tryReassociate. With simple pattern like add/mul this may be not a big deal. But the situation gets much worse when I try to add support for min/max. Min/Max may be represented by several instructions and can take different forms. In order reduce complexity for upcoming min/max support we need to restructure the code a bit to avoid mentioned code duplication.

Diff Detail

Event Timeline

ebrevnov created this revision.Sep 25 2020, 1:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 25 2020, 1:53 AM
ebrevnov requested review of this revision.Sep 25 2020, 1:53 AM
mkazantsev accepted this revision.Oct 29 2020, 9:29 PM

LGTM

llvm/lib/Transforms/Scalar/NaryReassociate.cpp
291

Return after unreachable not needed.

This revision is now accepted and ready to land.Oct 29 2020, 9:29 PM