RFR: 8373524: C2: no reachable node should have no use

Christian Hagedorn chagedorn at openjdk.org
Wed Dec 17 08:40:59 UTC 2025


On Tue, 16 Dec 2025 10:02:46 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> The failure occurs because `PhiNode::Ideal` uses `set_req` to update
> an input of a `Phi`. That causes the previous input to be disconnected
> but because of the use of `set_req`, the previous input that has no
> use is not enqueued for `igvn` to be reclaimed. The fix is to use
> `set_req_X` instead. I replaced uses of `set_req` with `set_req_X` in
> `PhiNode::Ideal` where I thought it made sense.

Otherwise, looks good!

src/hotspot/share/opto/cfgnode.cpp line 2599:

> 2597:             Node* phi = mms.memory();
> 2598:             for (uint i = 1; i < req(); ++i) {
> 2599:               if (phi->in(i) == this)  phi->set_req_X(i, phi, phase);

While at it, we should add braces:

Suggestion:

              if (phi->in(i) == this) {
                phi->set_req_X(i, phi, phase);
              }

test/hotspot/jtreg/compiler/c2/TestNodeWithNoUseAfterPhiIdeal.java line 1:

> 1: /*

Since this is about IGVN, you could move the test to `compiler/igvn`.

test/hotspot/jtreg/compiler/c2/TestNodeWithNoUseAfterPhiIdeal.java line 33:

> 31: 
> 32: package compiler.c2;
> 33: public class TestNodeWithNoUseAfterPhiIdeal {

Suggestion:


public class TestNodeWithNoUseAfterPhiIdeal {

-------------

Marked as reviewed by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28841#pullrequestreview-3586583247
PR Review Comment: https://git.openjdk.org/jdk/pull/28841#discussion_r2626088702
PR Review Comment: https://git.openjdk.org/jdk/pull/28841#discussion_r2626096607
PR Review Comment: https://git.openjdk.org/jdk/pull/28841#discussion_r2626089810


More information about the hotspot-compiler-dev mailing list