[llvm] [SimpleLoopUnswitch] Allow trivial unswitch when exit LCSSA is a header PHI (PR #222962)
Dark Steve via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 00:13:04 PDT 2026
================
@@ -790,6 +807,18 @@ static bool unswitchTrivialBranch(Loop &L, CondBrInst &BI, DominatorTree &DT,
rewritePHINodesForExitAndUnswitchedBlocks(*LoopExitBB, *UnswitchedBB,
*ParentBB, *OldPH, FullUnswitch);
+ // OldPH branches here without entering the loop, so a header PHI is still
+ // its entry value. Read it from NewPH, the preheader created by the split.
+ if (TrivialFromHeader)
+ for (PHINode &PN : UnswitchedBB->phis())
+ for (unsigned I = 0, E = PN.getNumIncomingValues(); I != E; ++I) {
----------------
PrasoonMishra wrote:
Done.
(Added the braces to the `if` block as that seemed cleaner)
https://github.com/llvm/llvm-project/pull/222962
More information about the llvm-commits
mailing list