-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8330158: C2: Loop strip mining uses ABS with min int #18813
Conversation
👋 Welcome back roland! A progress list of the required criteria for merging this PR into |
@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:
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 126 new commits pushed to the
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 |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, I agree with this reasoning.
Have you tried running tests with #18751 applied?
Thanks for reviewing this.
I only ran the particular test that you mentioned in the bug. |
All right, let me run tests with #18751 applied and see if we have any surprises. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two comments
int scaled_iters = (int)scaled_iters_long; | ||
int short_scaled_iters = LoopStripMiningIterShortLoop* ABS(stride); | ||
if ((jlong)scaled_iters != scaled_iters_long) { | ||
// Remove outer loop and safepoint (too few iterations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put more extended comment here. What you have in PR description would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment. Does it look good to you?
src/hotspot/share/opto/loopnode.cpp
Outdated
remove_outer_loop_and_safepoint(igvn); | ||
return; | ||
} | ||
int short_scaled_iters = LoopStripMiningIterShortLoop * ABS(stride); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So stride is not MIN_INT here but the expression still can overflow. Should we use jlong
for expression and short_scaled_iters
? iter_estimate
is jlong
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I updated the patch as suggested.
src/hotspot/share/opto/loopnode.cpp
Outdated
remove_outer_loop_and_safepoint(igvn); | ||
return; | ||
} | ||
int short_scaled_iters = LoopStripMiningIterShortLoop * ABS(stride); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it true that stride
can be MIN_INT here, if LoopStripMiningIter == 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a test for LoopStripMiningIter == 1
earlier in the method that causes the method to return.
There's also a less obvious use of an abs() idiom in LoopLimitNode::Ideal, when it does
if stride_con is negative. Does it make sense to fix that as part of this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I ran Maven CTW, Fuzzer tests, and the rest of OpenJDK jtregs with my ABS-checking patch applied, and there are no surprises. Looks good! |
There was a problem hiding this 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.
@shipilev @dean-long @vnkozlov @martinuy thanks for the reviews |
/integrate |
Going to push as commit c615c18.
Your commit was automatically rebased without conflicts. |
This fixes 3 calls to ABS with a min int argument. I think all of them
are harmless:
in
PhaseIdealLoop::exact_limit()
, I removed the call to ABS. Thecheck is for a stride of 1 or -1.
in
OuterStripMinedLoopNode::adjust_strip_mined_loop()
, for thecomputation of
scaled_iters_long
, the stride is passed toABS()
and then implicitly casted to long. I now cast the stride to long
before
ABS()
. For a min int stride,LoopStripMiningIter * stride
overflows the int range for all values of
LoopStripMiningIter
except 0 or 1. Those values are handled early on in that method. So
for a min in stride:
is always true and the method returns early.
in
OuterStripMinedLoopNode::adjust_strip_mined_loop()
, thecomputation of
short_scaled_iters
also callsABS()
with thestride as argument. But the result of that computation is only used
if the test for:
doesn't cause an early return of the method. I reordered statements
so the
ABS()
calls happens after that test which will cause an earlyreturn if the stride is min int.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18813/head:pull/18813
$ git checkout pull/18813
Update a local copy of the PR:
$ git checkout pull/18813
$ git pull https://git.openjdk.org/jdk.git pull/18813/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18813
View PR using the GUI difftool:
$ git pr show -t 18813
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18813.diff
Webrev
Link to Webrev Comment