-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8307619: C2 failed: Not monotonic (AndI CastII LShiftI) in TestShiftCastAndNotification.java #13908
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
Conversation
…astAndNotification.java
👋 Welcome back epeter! A progress list of the required criteria for merging this PR into |
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.
That looks good to me! As we've discussed offline, I'm also afraid, that there are more such cases where we do not handle top
correctly during CCP. Might be worth to further investigate at some point.
@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:
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 110 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 |
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.
@chhagedorn @TobiHartmann thanks for the reviews! |
Going to push as commit b6a9f5c.
Your commit was automatically rebased without conflicts. |
The Problem
During CCP, we get to a state like that:
We call
AddINode::Value
during CCP, and inMulNode::AndIL_shift_and_mask_is_always_zero
weuncast
both inputs, which leaves us withLShiftI
andConI
as the "true" inputs. They both have non-top types, and so we determine that thisAndI-LShiftI
combination always leads tozero
: ThePhi
has a constant type (int:4
). So this leaves the lowest 4 bits zero after theLShiftI
. Then and-ing that withint:3
means we extract the lowest 3 bits that are zero. So the result is provably always zero - that is the idea.Then, we have some type updates (here of
x
andPhi
andLShiftI
), and the graph looks like this:This leads to
shift2
failing to have constant type:jdk/src/hotspot/share/opto/mulnode.cpp
Lines 1964 to 1967 in a6b72f5
And with that, we fall back to
MulNode::Value
:jdk/src/hotspot/share/opto/mulnode.cpp
Lines 559 to 566 in a6b72f5
In
MulNode::Value
we detect that theCastII
has typetop
, and returntop
forAndI
.CCP expects the types to become more wide over time, so going from
int:0
totop
is the wrong direction.Solution
The problem is with the relatively rare
CastII
still beingtop
- this seems to be very rare. But the new regression testTestShiftCastAndNotification.java
seems to create exactly that case, in combination with-XX:StressCCP
.We should guard against
top
in one of theAndI
inputs insideMulNode::AndIL_shift_and_mask_is_always_zero
. This will prevent it from detecting the zero-case, untillMulNode::Value
would get a chance to compute a non-top type.Argument for Solution
Is there still a threat from
MulNode::AndIL_shift_and_mask_is_always_zero
computing a zero first, andMulNode::Value
a type that does not include zero after ward?As types only widen during CCP, having a zero first means that all inputs now are non-top - in fact they are all
T_INT
. Since types only widen in the inputs, and azero
combination was possible first, it must also be possible later.Testing
It used to reproduce with
-XX:RepeatCompilation=1000
very quickly, by restricting to that single failing method.This seems fixed now, I verified it locally.
Passes up to tier5 and stress testing.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13908/head:pull/13908
$ git checkout pull/13908
Update a local copy of the PR:
$ git checkout pull/13908
$ git pull https://git.openjdk.org/jdk.git pull/13908/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13908
View PR using the GUI difftool:
$ git pr show -t 13908
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13908.diff
Webrev
Link to Webrev Comment