RFR: 8361140: Missing OptimizePtrCompare check in ConnectionGraph::reduce_phi_on_cmp [v3]

Guanqiang Han duke at openjdk.org
Thu Jul 10 14:32:57 UTC 2025


> When running with `-XX:-OptimizePtrCompare` (which disables pointer comparison optimization), the compiler may hit an assertion failure in debug builds because `optimize_ptr_compare` is still being called. This violates the intended usage of the flag and leads to unexpected crashes.
> 
> This patch adds an early return to `reduce_phi_on_cmp` when `OptimizePtrCompare` is false. Since the optimization relies on `optimize_ptr_compare` for static reasoning about comparisons, there's no benefit in proceeding with `reduce_phi_on_cmp` when this flag is disabled.

Guanqiang Han 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 five additional commits since the last revision:

 - update regression test
 - Merge remote-tracking branch 'upstream/master' into 8361140
 - update modification and add regression test
 - Merge remote-tracking branch 'upstream/master' into 8361140
 - 8361140: Missing OptimizePtrCompare check in ConnectionGraph::reduce_phi_on_cmp
   
   When running with `-XX:-OptimizePtrCompare` (which disables pointer comparison optimization), the compiler may hit an assertion failure in debug builds because `optimize_ptr_compare` is still being called. This violates the intended usage of the flag and leads to unexpected crashes.
   
   This patch adds an early return to `reduce_phi_on_cmp` when `OptimizePtrCompare` is false. Since the optimization relies on `optimize_ptr_compare` for static reasoning about comparisons, there's no benefit in proceeding with `reduce_phi_on_cmp` when this support is disabled.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/26125/files
  - new: https://git.openjdk.org/jdk/pull/26125/files/2feca6a8..fd6f90f5

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

  Stats: 1158 lines in 25 files changed: 452 ins; 663 del; 43 mod
  Patch: https://git.openjdk.org/jdk/pull/26125.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26125/head:pull/26125

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


More information about the hotspot-compiler-dev mailing list