This patch adds folding freeze into phi if it has only one operand to target.
Won't this let through something like a constant vector with one undef element? Maybe just use the usual guaranteed-not-undef query here?
Can you also add a test with an all-constant phi, in which case the freeze will get dropped completely? I believe the code also handles that case.
As a possible followup: This code could be generalized a bit by using "constant && !constexpr" for non-freeze and "guaranteed-not-undef" (without any constant checks) for freeze, with some appropriate renames. This would basically change the transform from splitting into "constant" and "non-constant" inputs, into "foldable" and "non-foldable" inputs (where "foldable = constant" for most cases).
Oh right, that makes sense. In that case the whole phi is "guaranteed not undef", so we don't ever get here.