[LSR] Preserve LCSSA when rewriting instruction with PHI user
Fixes https://github.com/llvm/llvm-project/issues/61182. LoopStrengthReduce may sometimes break LCSSA form when applying a rewrite for an instruction used in a PHI. It happens if: - The PHI is in a loop exit block, - The edge from the corresponding exiting block to that exit is critical, - The PHI has at least two inputs coming from loop blocks, - and the rewritten instruction is inserted in the loop. In such case we split the critical edge and then replace PHI inputs with the rewritten instruction. However ExitBlock is no longer a loop exit, so LCSSA form is broken. This patch fixes it by collecting all inserted instructions for PHIs whose parent block is not a loop exit and then forming LCSSA for them. Differential Revision: https://reviews.llvm.org/D146811
Loading
Please sign in to comment