RFR: 8361140: Missing OptimizePtrCompare check in ConnectionGraph::reduce_phi_on_cmp [v2]
Guanqiang Han
duke at openjdk.org
Thu Jul 10 05:09:39 UTC 2025
On Mon, 7 Jul 2025 12:11:46 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> 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 three additional commits since the last revision:
>>
>> - 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.
>
> src/hotspot/share/opto/escape.cpp line 981:
>
>> 979: if (!OptimizePtrCompare) {
>> 980: return;
>> 981: }
>
> Thanks for working on this! IIUC, having the bailout here will fail to reduce the phi which could be unexpected. Shouldn't we just return `UNKNOWN` from within `ConnectionGraph::optimize_ptr_compare()` when we run without `OptimizePtrCompare`?
>
> On a separate note, can you also add a regression test? Maybe you can also just add a run with `-XX:-OptimizePtrCompare` - maybe together with `-XX:+VerifyReduceAllocationMerges` for more verification - to `compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java`.
>
> @JohnTortugo you might also want to have a look at this.
hi @chhagedorn , I already update PR and add regression test. Please take another look when you have time .
Thanks a lot.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26125#discussion_r2196583002
More information about the hotspot-compiler-dev
mailing list