[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
Fri Sep 11 20:39:18 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,
----------------
PrasoonMishra wrote:
I agree the name is stale. I originally had two utilities, so the two questions stayed distinct, but I was a bit skeptical about the duplicated phi walk, so I merged them as you suggested. That just leaves the name doing double duty. Hence, I merged it as per your suggestion. But now it just leaves the name doing double duty.
`areLoopExitPHIsTrivial` covers both cases honestly and matches the doc comment the function already carries. Does this name work for you? I'll update the comment along with it.
https://github.com/llvm/llvm-project/pull/222962
More information about the llvm-commits
mailing list