This patch fixes pr43326(https://bugs.llvm.org/show_bug.cgi?id=43326) and pr48212(https://bugs.llvm.org/show_bug.cgi?id=48212). The test cases in pr43326 and pr48212 are added in lit tests.
Currently when we move reduction phis to the right place, this pass assumes the first phi in loop headers is an induction phi, skips the first phi and assume 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 consider an phi as a candidate reduction phi to move only when it is indeed a reduction phi across outer and inner loop.
This line can now be removed.