I didn't recognize that it's still WIP until some point, so some nitpicking comments aren't very useful probably...
Are we somehow limited that the argument must be an OriginalPlan or can it be some Plan? Specifically, what if I want to try some optimization on already cloned VPlan such that I'm not sure if it's profitable or not, so I want to create a clone of the Plan instead of transforming in place. Would I be able to use that clone method?
Why don't we use cast similar to line 8721? It's also not clear why we have early continue above, but it might actually have the same answer.
nit: I'd move it out of the loop.
That's mostly copy of the lambda above. Can we unify them somehow?
I think it deserves a dedicated comment, especially because it's surprising to see new recipes created inside the block of code starting with the comment "Remove dead instrutions."
I think that it would be beneficial to address this even in the WIP stage of the patch and not during the final polishing.
Missed in the copy-paste?