From c3c59413be1a05e5b2362bb84d5fd50a8cbceff0 Mon Sep 17 00:00:00 2001 From: Quan Anh Mai Date: Fri, 17 Apr 2026 14:09:07 +0000 Subject: [PATCH] 8378966: C2: PhaseIdealLoop::pin_nodes_dependent_on must not be called with nullptr Reviewed-by: chagedorn, aseoane --- src/hotspot/share/opto/loopopts.cpp | 14 ++++++++++++-- src/hotspot/share/opto/split_if.cpp | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 11b23d7c365..ccd53129a87 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1307,7 +1307,14 @@ Node* PhaseIdealLoop::place_outside_loop(Node* useblock, IdealLoopTree* loop) co bool PhaseIdealLoop::identical_backtoback_ifs(Node *n) { - if (!n->is_If() || n->is_BaseCountedLoopEnd()) { + if (!n->is_If()) { + return false; + } + if (n->outcnt() != n->as_If()->required_outcnt()) { + assert(false, "malformed IfNode with %d outputs", n->outcnt()); + return false; + } + if (n->is_BaseCountedLoopEnd()) { return false; } if (!n->in(0)->is_Region()) { @@ -1433,7 +1440,10 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) { // Check some safety conditions if (iff->is_If()) { // Classic split-if? - if (iff->in(0) != n_ctrl) { + if (iff->outcnt() != iff->as_If()->required_outcnt()) { + assert(false, "malformed IfNode with %d outputs", iff->outcnt()); + return; + } else if (iff->in(0) != n_ctrl) { return; // Compare must be in same blk as if } } else if (iff->is_CMove()) { // Trying to split-up a CMOVE diff --git a/src/hotspot/share/opto/split_if.cpp b/src/hotspot/share/opto/split_if.cpp index c1303f0d0db..e5f8043ae19 100644 --- a/src/hotspot/share/opto/split_if.cpp +++ b/src/hotspot/share/opto/split_if.cpp @@ -704,6 +704,9 @@ void PhaseIdealLoop::do_split_if(Node* iff, RegionNode** new_false_region, Regio new_true = ifpx; } } + assert(new_false != nullptr, "iff is malformed"); + assert(new_true != nullptr, "iff is malformed"); + _igvn.remove_dead_node(new_iff, PhaseIterGVN::NodeOrigin::Speculative); // Lazy replace IDOM info with the region's dominator replace_node_and_forward_ctrl(iff, region_dom);