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

8299179: ArrayFill with store on backedge needs to reduce length by 1 #11904

Closed
wants to merge 3 commits into from

Conversation

eme64
Copy link
Contributor

@eme64 eme64 commented Jan 9, 2023

Context
ArrayFill replaces CountedLoop like this:
for(int i = 5; i < 15; i++) { arr[i] = 88; }
with
jint_fill(arr, 5, len, 88) (CallLeafNoFPNode, intrinsified)
where len = limit - init.
This is implemented for byte, short and int (long not yet supported).

Solution
This assumes that the store is in the body of the loop. In rare cases, the store is pinned to the backedge, and so it is executed after the exit check, hence in all iterations except the last one. In those cases we need to set len = limit - init - 1.

Details
How does a store land on the backedge?
test_002 was first reported to me. I reduced it down to a conceptually easier test_102.
We have a loop, where the first block only has a single successor. This block contains the store that it eventually detected as a ArrayFill. This block passes the checks of clone_loop_head during parsing: the block is copied before the loop and onto the backedge.

FYI
I saw that we seem to currently mostly unroll such loops, instead of applying the ArrayFill. Follow up RFE JDK-8299808.


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-8299179: ArrayFill with store on backedge needs to reduce length by 1

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11904

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 9, 2023

👋 Welcome back epeter! 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 Jan 9, 2023

@eme64 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 Jan 9, 2023
@eme64 eme64 changed the title ArrayFill with store on backedge needs to reduce length by 1 8299179: ArrayFill with store on backedge needs to reduce length by 1 Jan 9, 2023
@eme64 eme64 marked this pull request as ready for review January 10, 2023 08:23
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 10, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 10, 2023

Webrevs

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.

Nice analysis and test. Looks good to me.

src/hotspot/share/opto/loopTransform.cpp Outdated Show resolved Hide resolved
@openjdk
Copy link

openjdk bot commented Jan 10, 2023

@eme64 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:

8299179: ArrayFill with store on backedge needs to reduce length by 1

Reviewed-by: thartmann, kvn

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 24 new commits pushed to the master branch:

  • c595f96: 8299278: tools/jpackage/share/AddLauncherTest.java#id1 failed AddLauncherTest.bug8230933
  • 3c99e78: 8298735: Some tools/jpackage/windows/* tests fails with jtreg test timeout
  • 5a51ef2: 8297874: get_dump_directory() in jfrEmergencyDump.cpp should pass correct length to jio_snprintf
  • a86b6f6: 8299183: Invokers.checkExactType passes parameters to create WMTE in opposite order
  • 8b0133f: 8299259: C2: Div/Mod nodes without zero check could be split through iv phi of loop resulting in SIGFPE
  • d68de02: 8299845: Remove obsolete comments in DirtyCardToOopClosure::get_actual_top
  • debe587: 8298381: Improve handling of session tickets for multiple SSLContexts
  • eab1e62: 8297487: G1 Remark: no need to keep alive oop constants of nmethods on stack
  • c8a8388: 8299789: Compilation of gtest causes build to fail if runtime libraries are in different dirs
  • 5f37cbe: 8297572: Remove unused PrecisionStyle::Precise
  • ... and 14 more: https://git.openjdk.org/jdk/compare/4ba8122197e912db4894ed7fe395a8842268fbef...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 Jan 10, 2023
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
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.

Good.

Node* backedge = head->loopexit()->proj_out(1);
if (store->in(0) == backedge) {
len = new SubINode(len, _igvn.intcon(1));
_igvn.register_new_node_with_optimizer(len);
Copy link
Member

Choose a reason for hiding this comment

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

How about moving the earlier call to register_new_node_with_optimizer to after this block, so it is only called once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @dean-long . Just discussed it with @TobiHartmann . We have two new nodes here, one to compute
len = limit - init,
the other to decrement the len by 1:
len = len - 1.
Both are new nodes, and need to be registered with igvn. So we think it is correct the way it is now.

Copy link
Member

Choose a reason for hiding this comment

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

OK, that makes sense.

@eme64
Copy link
Contributor Author

eme64 commented Jan 12, 2023

Thanks @TobiHartmann @vnkozlov @dean-long for the help and reviews!
/integrate

@openjdk
Copy link

openjdk bot commented Jan 12, 2023

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

  • af8d3fb: 8264684: os::get_summary_cpu_info padded with spaces
  • 78b1686: 8227257: javax/swing/JFileChooser/4847375/bug4847375.java fails with AssertionError
  • 33f3bd8: Merge
  • 945ef07: 8299862: OfAddress setter should disallow heap segments
  • 636976a: 8299849: Revert JDK-8294461: wrong effectively final determination by javac
  • 0abb87a: 8299227: host exif.org not found in link in doc comment
  • de79162: 8299715: IR test: VectorGatherScatterTest.java fails with SVE randomly
  • 151450e: 8294744: AArch64: applications/kitchensink/Kitchensink.java crashed: assert(oopDesc::is_oop(obj)) failed: not an oop
  • 21d468e: 8299733: AArch64: "unexpected literal addressing mode" assertion failure with -XX:+PrintC1Statistics
  • 5826a07: 8299693: Change to Xcode12.4+1.1 devkit for building on macOS at Oracle
  • ... and 43 more: https://git.openjdk.org/jdk/compare/4ba8122197e912db4894ed7fe395a8842268fbef...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 12, 2023

@eme64 Pushed as commit d716ec5.

💡 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
4 participants