[LoopInterhcange] Handle movement of reduction phis appropriately
authorCongzhe Cao <congzhe.cao@huawei.com>
Mon, 31 May 2021 20:11:04 +0000 (16:11 -0400)
committerCongzheUalberta <congzhecao@gmail.com>
Mon, 31 May 2021 20:27:38 +0000 (16:27 -0400)
commitbfefde22b670359eddd7843573b63dc4326f33c1
tree9c987e43c5bb17d99dce7ea474da1b881a82c932
parent5c9fe816e3b6b9cdbf75758f2744a45f97c489f0
[LoopInterhcange] Handle movement of reduction phis appropriately

This patch fixes pr43326 and pr48212.

Currently when we move reduction phis to the right place,
loop interchange assumes the first phi in loop headers is
an induction phi, skips the first phi and assumes the rest
of phis are candidate reduction phis to move. However, it
may not always be the case.

This patch loops over all phis in loop headers and considers
a phi node as a candidate reduction phi to move only when it
is indeed a reduction phi across outer and inner loop.

Reviewed By: Whitney

Differential Revision: https://reviews.llvm.org/D102743
llvm/lib/Transforms/Scalar/LoopInterchange.cpp
llvm/test/Transforms/LoopInterchange/pr43326.ll [new file with mode: 0644]
llvm/test/Transforms/LoopInterchange/pr48212.ll [new file with mode: 0644]