https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98464
--- Comment #9 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 4 Jan 2021, linkw at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98464 > > --- Comment #8 from Kewen Lin <linkw at gcc dot gnu.org> --- > (In reply to Richard Biener from comment #5) > > 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. > > OK, just noticed that wrapper is only for simplify_replace_tree. Thanks for > fixing. But I still don't get why it's buggy for rpo_vn_valueize. Because rpo_vn_valueize argument can be a value handle SSA which does not need to be a definition on the path to the stmt we are simplifying. rpo_vn_valueize is called from (too) many contexts and I'm not 100% convinced we're only feeding it names available at the location we are processing. Note I think we should use 'b' and not SSA_NAME_DEF_STMT of the use but then this code is as-is since the rewrite and I don't feel tracking down fallout of changing this back now (but I'll try to remember for stage1, as well as somehow better dealing with dominated_by_w_unex)