If ExitBB already contains a phi with a constant incoming value, re-use
it instead of creating a new phi. If the incoming value of the re-used
phi node is not yet in LCSSA form it will get formed in subsequent
iterations, like for newly created ones.
This means we won't end up with multiple LCSSA phi nodes when an
existing PHI can already be re-used. This is in particular relevant for
code that needs to re-build LCSSA for some values on demand, like
SCEVExpander.
This patch ensures that only be a single LCSSA phi will be created and
re-used when expanding the same expressions multiple times.
Fixes #57000.
Is the new code to prevent creating identical PHI nodes part of the fix, or just an optimization? It isn't obviously related.