https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98464
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- But this sprime = eliminate_avail (gimple_bb (SSA_NAME_DEF_STMT (use)), use); should make it more conservative (compared to the more desirable use of gimple_bb (stmt) aka 'b'). The issue is really that dominated_by_p_w_unex is not "transitive" with respect to an intermediate immediate dominator chain. We can make that more consistent at least by doing sth like your patch but only in vn_valueize_wrapper. Longer term we need to think about a better way to do what dominated_by_p_w_unex is doing, avoding the issue with the intermediate dominators. In particular somehow address /* Before iterating we'd like to know if there exists a (executable) path from bb2 to bb1 at all, if not we can directly return false. For now simply iterate once. */ it might be possible to compute that in an optimistic way for the non-iterating scheme but for the iterative processing it needs some extra thought.