[llvm] [SimpleLoopUnswitch] Allow trivial unswitch when exit LCSSA is a header PHI (PR #222962)

Ehsan Amiri via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 12 15:14:16 PDT 2026


================
@@ -258,19 +258,29 @@ static void replaceLoopInvariantUses(const Loop &L, Value *Invariant,
 
 /// Check that all the LCSSA PHI nodes in the loop exit block have trivial
 /// incoming values along this edge.
+///
+/// If \p UsedHeaderPHI is non-null, an incoming value that is a PHI in the
+/// loop header is accepted too. *UsedHeaderPHI is set to true if that happens.
 static bool areLoopExitPHIsLoopInvariant(const Loop &L,
----------------
amehsan wrote:

> `areLoopExitPHIsTrivial` covers both cases

Yeah, this name looks good. I will go over everything this time, so we can hopefully merge it after your next update.

https://github.com/llvm/llvm-project/pull/222962


More information about the llvm-commits mailing list