[NFC][NARY-REASSOCIATE] Restructure code to aviod isPotentiallyReassociatable
authorEvgeniy Brevnov <ybrevnov@azul.com>
Fri, 25 Sep 2020 04:46:20 +0000 (11:46 +0700)
committerEvgeniy Brevnov <ybrevnov@azul.com>
Fri, 4 Dec 2020 09:19:43 +0000 (16:19 +0700)
commit061cebb46f6c484322719f906a16ebc7a1bc5fff
treefe17af5976d8cea53b174cb280787a7275e3aa46
parentf61c29b3a725a620c67355a519788a96be5d5651
[NFC][NARY-REASSOCIATE] Restructure code to aviod isPotentiallyReassociatable

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.

Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D88286
llvm/include/llvm/Transforms/Scalar/NaryReassociate.h
llvm/lib/Transforms/Scalar/NaryReassociate.cpp