Skip to content

8387369: Extend ReduceAllocationMerges to CheckCastPP and SubTypeCheck nodes#31699

Open
raneashay wants to merge 1 commit into
openjdk:masterfrom
raneashay:JDK-8387369-escape-analysis-checkcastpp-subtypecheck
Open

8387369: Extend ReduceAllocationMerges to CheckCastPP and SubTypeCheck nodes#31699
raneashay wants to merge 1 commit into
openjdk:masterfrom
raneashay:JDK-8387369-escape-analysis-checkcastpp-subtypecheck

Conversation

@raneashay

@raneashay raneashay commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

This patch strengthens the escape analysis in ReduceAllocationMerges to
now recognize merges whose users are either CheckCastPP and
SubTypeCheck nodes, which in turn enables optimizations over
conditional statements that merge values from two or more allocations
(see the JBS issue for code snippet). The key idea is to hoist the
CheckCastPP and SubTypeCheck nodes before the Phi node, thus
isolating the allocation.

Prior to this patch, neither CheckCastPP nodes nor SubTypeCheck
nodes were recognized as reducible, so merge nodes were left in place
and allocation nodes could not be replaced with scalars. With this
patch, each allocation node is isolated and non-escaping, so ordinary
scalar replacment is able to remove the node.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8387369: Extend ReduceAllocationMerges to CheckCastPP and SubTypeCheck nodes (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31699/head:pull/31699
$ git checkout pull/31699

Update a local copy of the PR:
$ git checkout pull/31699
$ git pull https://git.openjdk.org/jdk.git pull/31699/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31699

View PR using the GUI difftool:
$ git pr show -t 31699

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31699.diff

Using Webrev

Link to Webrev Comment

This patch strengthens the escape analysis in ReduceAllocationMerges to
now recognize merges whose users are either `CheckCastPP` and
`SubTypeCheck` nodes, which in turn enables optimizations over
conditional statements that merge values from two or more  allocations
(see the JBS issue for code snippet).  The key idea is to hoist the
`CheckCastPP` and `SubTypeCheck` nodes before the Phi node, thus
isolating the allocation.

Prior to this patch, neither `CheckCastPP` nodes nor `SubTypeCheck`
nodes were recognized as reducible, so merge nodes were left in place
and allocation nodes could not be replaced with scalars.  With this
patch, each allocation node is isolated and non-escaping, so ordinary
scalar replacment is able to remove the node.
@bridgekeeper

bridgekeeper Bot commented Jun 26, 2026

Copy link
Copy Markdown

👋 Welcome back arane! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jun 26, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jun 26, 2026
@openjdk

openjdk Bot commented Jun 26, 2026

Copy link
Copy Markdown

@raneashay The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk

openjdk Bot commented Jun 26, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-compiler. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Jun 26, 2026
@raneashay raneashay changed the title 8387369: Extend ReduceAllocationMerges to CheckCastPP and SubTypeCheck nodes 8387369: Extend ReduceAllocationMerges to CheckCastPP and SubTypeCheck nodes Jun 26, 2026
@raneashay

Copy link
Copy Markdown
Contributor Author

Here are the numbers from the included JMH microbenchmark on an x64 machine, reordered for easier legibility:

Benchmark                                                    Mode  Cnt   Score   Error  Units
AllocationMerges.NopRAM.testInstanceOfNullMerge_runner       avgt   15   8.234 ± 1.271  ms/op
AllocationMerges.YesRAM.testInstanceOfNullMerge_runner       avgt   15   2.153 ± 0.005  ms/op

Benchmark                                                    Mode  Cnt   Score   Error  Units
AllocationMerges.NopRAM.testInstanceOfWithBinding_runner     avgt   15  15.586 ± 2.553  ms/op
AllocationMerges.YesRAM.testInstanceOfWithBinding_runner     avgt   15   1.883 ± 0.005  ms/op

Benchmark                                                    Mode  Cnt   Score   Error  Units
AllocationMerges.NopRAM.testInstanceOfWithoutBinding_runner  avgt   15  16.309 ± 4.730  ms/op
AllocationMerges.YesRAM.testInstanceOfWithoutBinding_runner  avgt   15   2.153 ± 0.006  ms/op
``

@mlbridge

mlbridge Bot commented Jun 26, 2026

Copy link
Copy Markdown

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant