[llvm] [LoopInterchange] Reject inner preheader PHIs with non-identical incoming values (PR #203842)
Madhur Amilkanthwar via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 02:01:53 PDT 2026
================
@@ -1541,7 +1531,26 @@ bool LoopInterchangeLegality::canInterchangeLoops(unsigned InnerLoopId,
return false;
}
- if (!areInnerLoopLatchPHIsSupported(InnerLoop)) {
+ BasicBlock *InnerLoopPreHeader = InnerLoop->getLoopPreheader();
+ // Inner-preheader PHIs are removed by substituting each with its first
+ // incoming value. That is only correct when all incoming values are the
+ // same; a PHI with different incoming values would produce the wrong result.
+ if (InnerLoopPreHeader != OuterLoop->getHeader() &&
+ any_of(InnerLoopPreHeader->phis(),
+ [](PHINode &PHI) { return !all_equal(PHI.incoming_values()); })) {
----------------
madhur13490 wrote:
yes, I think I was over-thinking. Made the changes.
https://github.com/llvm/llvm-project/pull/203842
More information about the llvm-commits
mailing list