RFR: 8374180: C2 crash in PhaseCCP::verify_type - fatal error: Not monotonic [v2]

Quan Anh Mai qamai at openjdk.org
Sun Dec 28 07:35:32 UTC 2025


> Hi,
> 
> The issue here is the inconsistency in computing the `_widen` field of the `TypeInt`. At the first step, the types of the operands are:
> 
>     t1 = int:0
>     t2 = int:-2..3, widen = 3
> 
> Since the type of the first operand is a constant zero, `AddNode::Value` returns the type of the second operand directly, as `x ^ 0 == x for all x`. In the second step, `t1` is widened to `0..2`. This triggers the real computation of the result. The algorithm then splits `t2` into `t21 = int:-2..-1` and `t22 = int:0..3`. The `Xor` of these with `t1` are `r1 = int:-4..-1` and `r2 = int:0..3`. As both have `_hi - _lo <= SMALL_TYPEINT_THRESHOLD == 3`, their `_widen`s are normalized to `0`. As a result, their `meet` also has `_widen == 0`. This value is smaller than that from the previous step, which was `3`, which leads to the failure.
> 
> The root cause here is that, the `_widen` value of a node should be computed and normalized on the whole range of the node, not on its subranges, which may normalize it to `0` in more cases than what is expected. As a result, my proposed solution is to ignore the `_widen` value of the subranges, and pass the expected `_widen` value when composing the final result.
> 
> Please take a look and leave your reviews, thanks a lot.

Quan Anh Mai 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:

 - copyright year
 - Merge branch 'master' into widen
 - RangeInference::infer should ensure correct value of _widen

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/28952/files
  - new: https://git.openjdk.org/jdk/pull/28952/files/f9b8615c..2fb0af13

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

  Stats: 2288 lines in 1000 files changed: 597 ins; 281 del; 1410 mod
  Patch: https://git.openjdk.org/jdk/pull/28952.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28952/head:pull/28952

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


More information about the hotspot-compiler-dev mailing list