Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8297724: Loop strip mining prevents some empty loops from being eliminated #11699

Closed
wants to merge 4 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Dec 15, 2022

When an empty loop is found, it's removed and as a consequence the
outer strip mine loop and the safepoint that it contains are also
removed. A counted loop is empty if it has the minimum number of nodes
that a well formed counted loop contains. In some cases, the loop has
extra nodes and the safepoint in the outer loop is the only node that
keeps those extra nodes alive. If the safepoint was to be removed,
then the counted loop would have the minimum number of nodes and be
considered empty. But the safepoint can't be removed until the loop is
considered empty which only happens if it has the minimum of nodes. As
a result, these loops are not removed. Note that now that the loop
strip mining loop nest is constructed even if UseCountedLoopSafepoints
is false, there's a regression where some loops used to be removed as
empty before but not anymore.

The fix I propose is to extend IdealLoopTree::do_remove_empty_loop()
so it handles those cases. If it encounters a loop with no flow
control in the loop body but a number of nodes greater than the
minimum number of nodes, it starts from the extra nodes in the loop
body and follows uses until it finds a side effect, ignoring the
safepoint of the outer loop. If it finds none, then the extra nodes
can be removed and the loop is empty. This also works if the extra
nodes are kept alive by the safepoints of 2 different counted loops
and one can only be proven empty if the other one is as well (and the
other one proven empty if the first one is) and should work even if
there are more than 2 nodes involved..


Progress

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

Issue

  • JDK-8297724: Loop strip mining prevents some empty loops from being eliminated

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11699

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 15, 2022

👋 Welcome back roland! 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
Copy link

openjdk bot commented Dec 15, 2022

@rwestrel 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 added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Dec 15, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 15, 2022
@mlbridge
Copy link

mlbridge bot commented Dec 15, 2022

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you for fixing it.

@openjdk
Copy link

openjdk bot commented Dec 15, 2022

@rwestrel This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8297724: Loop strip mining prevents some empty loops from being eliminated

Reviewed-by: kvn, thartmann

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 77 new commits pushed to the master branch:

  • ba942c2: 8298244: AArch64: Optimize vector implementation of AddReduction for floating point
  • 7938f8c: 8298639: Perform I/O operations in bulk for RandomAccessFile
  • bfa921a: 8160404: RelocationHolder constructors have bugs
  • bf9a8ce: 8249826: 5 javax/net/ssl/SSLEngine tests use @ignore w/o bug-id
  • 0eeaeb8: 8298808: Check script code on detecting the base locales
  • 81e23ab: 8298809: Clean up vm/compiler/InterfaceCalls JMH
  • 3696711: Merge
  • f771c56: 8298797: Specification of some restricted methods is incorrect
  • 0ba4734: 8287699: jdk/jfr/api/consumer/TestRecordingFileWrite.java fails with exception: java.lang.Exception: Found event that should not be there.
  • c47e64e: 8297979: ZGC: Ensure consistent MemoryUsage from MemoryMXBean.getHeapMemoryUsage()
  • ... and 67 more: https://git.openjdk.org/jdk/compare/042b7062f19b313f31b228bd96d2a74cc1165ab9...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 15, 2022
Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I'm running some testing and will report back once it passed.

src/hotspot/share/opto/loopTransform.cpp Outdated Show resolved Hide resolved
rwestrel and others added 2 commits December 16, 2022 15:03
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
…java

Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests passed.

@rwestrel
Copy link
Contributor Author

@vnkozlov @TobiHartmann thanks for the reviews (and testing).

@rwestrel
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Dec 21, 2022

Going to push as commit 88bfe4d.
Since your change was applied there have been 126 commits pushed to the master branch:

  • a7d6de7: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes
  • b005013: 8296275: Write a test to verify setAccelerator method of JMenuItem
  • 85f9b37: 8297682: Use Collections.emptyIterator where applicable
  • f36e144: 8299025: BMPImageReader.java readColorPalette could use staggeredReadByteStream
  • f56285c: 8299146: No copyright statement on ArtifactResolverException.java
  • 396a9bf: 8298913: Add override qualifiers to Relocation classes
  • 386db07: Merge
  • f4d7f43: 8299123: [BACKOUT] 4512626 Non-editable JTextArea provides no visual indication of keyboard focus
  • 03afec1: 8298162: Test PrintClasses hits assert when run with code that retransform classes
  • 03d9927: 8298061: vmTestbase/nsk/sysdict/vm/stress/btree/btree012/btree012.java failed with "fatal error: refcount has gone to zero"
  • ... and 116 more: https://git.openjdk.org/jdk/compare/042b7062f19b313f31b228bd96d2a74cc1165ab9...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 21, 2022
@openjdk openjdk bot closed this Dec 21, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 21, 2022
@openjdk
Copy link

openjdk bot commented Dec 21, 2022

@rwestrel Pushed as commit 88bfe4d.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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 integrated Pull request has been integrated
3 participants