https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90571
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Turning indirect calls into direct ones might be important enough to also handle int x, y; int f() { return x; } int g() { return y; } int t0(bool b) { int (*i)() = b ? &f : &g; x = 1; return i(); } int main(int ac, char**) { return t0(ac & 1); } like where there are statements before the indirect call that prevent it from being simply duplicated into the predecessor blocks. The transformation "primitive" would then be to duplicate the joiner up to the call and the "interesting" part of it is creating all required PHI nodes (unless you want to make SSA rewrite deal with this somehow). Sinking stmts below the call and limiting the amount of copying is important. Note there are related PRs for that we miss to sink/hoist stmts through PHI nodes when that reduces the number of PHI nodes. The transform would likely split the block, insert "block-closed" PHI nodes in the tail part for all SSA names defined in the first half and live over the new edge and then duplicate the first half re-wiring edges as needed. This is as opposed to the original testcase where a simpler pattern-matching scheme could be invented. I wonder how the "original" testcase looked like - the one in this bug is probably simplified from real-world code?