diff --git a/src/hotspot/share/opto/loopPredicate.cpp b/src/hotspot/share/opto/loopPredicate.cpp index e72a884b41a..067b7c44dee 100644 --- a/src/hotspot/share/opto/loopPredicate.cpp +++ b/src/hotspot/share/opto/loopPredicate.cpp @@ -333,13 +333,6 @@ IfProjNode* PhaseIdealLoop::create_new_if_for_predicate(IfProjNode* cont_proj, N _igvn.add_input_to(rgn, if_uct); - // When called from beautify_loops() idom is not constructed yet. - if (_idom != nullptr) { - Node* ridom = idom(rgn); - Node* nrdom = dom_lca_internal(ridom, new_iff); - set_idom(rgn, nrdom, dom_depth(rgn)); - } - // If rgn has phis add new edges which has the same // value as on original uncommon_proj pass. assert(rgn->in(rgn->req() -1) == if_uct, "new edge should be last"); @@ -377,6 +370,14 @@ IfProjNode* PhaseIdealLoop::create_new_if_for_predicate(IfProjNode* cont_proj, N set_idom(iff, if_cont, dom_depth(iff)); } } + + // When called from beautify_loops() idom is not constructed yet. + if (_idom != nullptr) { + Node* ridom = idom(rgn); + Node* nrdom = dom_lca_internal(ridom, new_iff); + set_idom(rgn, nrdom, dom_depth(rgn)); + } + return if_cont->as_IfProj(); }