RFR: 8271056: C2: "assert(no_dead_loop) failed: dead loop detected" due to cmoving identity

Christian Hagedorn chagedorn at openjdk.java.net
Fri Oct 29 13:10:41 UTC 2021


In the testcase, an unsafe cmoving identity is applied in `PhiNode::Identity()` after parsing which replaces a loop phi in a dead loop creating a dead data loop which triggers the assertion. The problem is that `PhiNode::Identity()` assumes that a cmoving identity is always safe because `PhiNode::Ideal()` handles unsafe cases and only leaves safe cases to `PhiNode::Identity()`:
https://github.com/openjdk/jdk/blob/4c3491bfa5f296b80c56a37cb4fffd6497323ac2/src/hotspot/share/opto/cfgnode.cpp#L2051-L2055

However, the fix for [JDK-8268883 ](https://github.com/openjdk/jdk17/commit/6d8fc7249a3a1a2350c462f9c4fe38377856392f)added the following additional condition to wait for the region to be processed:
https://github.com/openjdk/jdk/blob/4c3491bfa5f296b80c56a37cb4fffd6497323ac2/src/hotspot/share/opto/cfgnode.cpp#L2047-L2053

This skips the process of an unsafe case in `PhiNode::Ideal()` in the testcase. Afterwards, the unsafe case is replaced unconditionally in `PhiNode::Identity()` resulting in a dead data loop.

I therefore propose to add the same check added in JDK-8268883 to `PhiNode::Identity()` to prevent that.

Thanks,
Christian

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

Commit messages:
 - 8271056: C2: "assert(no_dead_loop) failed: dead loop detected" due to cmoving identity

Changes: https://git.openjdk.java.net/jdk/pull/6172/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6172&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8271056
  Stats: 87 lines in 2 files changed: 85 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6172.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6172/head:pull/6172

PR: https://git.openjdk.java.net/jdk/pull/6172


More information about the hotspot-compiler-dev mailing list