RFR: JDK-8309266: C2: assert(final_con == (jlong)final_int) failed: final value should be integer [v2]

Eric Nothum duke at openjdk.org
Mon Jun 19 07:29:23 UTC 2023


> **Acknowledgments**: Thanks to @quadhier for the preliminary work on this issue: https://github.com/openjdk/jdk/pull/14353
> 
> **JDK-8309266**: TestLoopLimitOverflowDuringCCP.java causes an assertion error (overflow check) in LoopLimitNode::Value. To fix the issue I added a check in LoopLimitNode::Value that verifies that the input nodes are ConI type nodes. 
> 
> Previously, TestLoopLimitOverflowDuringCCP would cause the assertion error in LoopLimitNode::Value, during PhaseCCP::analyze. The problem originated from PhaseCCP initializing all types to TOP, resulting in the Phi node from `int limit = flag ? 1000 : Integer.MAX_VALUE` being temporarily considered as Integer.MAX_VALUE. This happens as the Node for the Integer.MAX_VALUE case was already analyzed by CCP while the Node for the 1000 case was still initialized to TOP. When resolving the value of the Phi node, Integer.MAX_VALUE and TOP get merged to Integer.MAX_VALUE, which is then processed by LoopLimitNode::Value as a constant, resulting in the integer overflow.
> 
> By checking that the input nodes are ConI nodes in LoopLimitNode::Value, we avoid Phi nodes being misinterpreted during PhaseCCP. If the Phi nodes turn out to be constant they should rather be first transformed to ConI nodes.

Eric Nothum has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:

 - merge
 -  JDK-8309266: Cosmetic change to the if statement
 -  JDK-8309266: 1) Added TestLoopLimitOverflowDuringCCP to the jtreg tests 2) Verify in LoopLimitNode::Value that the input nodes are ConI type nodes.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/14490/files
  - new: https://git.openjdk.org/jdk/pull/14490/files/04a5a3d5..35017b8d

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14490&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14490&range=00-01

  Stats: 25527 lines in 777 files changed: 13951 ins; 8958 del; 2618 mod
  Patch: https://git.openjdk.org/jdk/pull/14490.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14490/head:pull/14490

PR: https://git.openjdk.org/jdk/pull/14490


More information about the hotspot-compiler-dev mailing list