-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8360561: PhaseIdealLoop::create_new_if_for_predicate hits "must be a uct if pattern" assert #26504
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
8360561: PhaseIdealLoop::create_new_if_for_predicate hits "must be a uct if pattern" assert #26504
Conversation
|
👋 Welcome back mchevalier! A progress list of the required criteria for merging this PR into |
|
@marc-chevalier 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 319 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 |
|
@marc-chevalier The following label will be automatically applied to this pull request:
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. |
|
Should these be done for |
|
@merykitty yes, probably, I was indeed looking into which flavors of |
|
After looking deeper, it seems that we don't have to do the same change: this crash doesn't seem possible in other situations because of the refinement (leading to Top integers) happening only in specific cases, and especially not for longs. Yet, we surely can do the change, seems correct to me. Also, even if it doesn't solve a crash, it can be beneficial (see the test with longs): it already worked, but now, we can get rid of a path, and the graph is simpler. Overall, we don't have to, but we can and should, so there it is! |
Webrevs
|
mhaessig
left a comment
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.
Thank you for working on this, @marc-chevalier! And the nice explanation.
The changes look good to me. Only the IR test needs a small fix.
test/hotspot/jtreg/compiler/igvn/CmpDisjointButNonOrderedRangesLong.java
Outdated
Show resolved
Hide resolved
TobiHartmann
left a comment
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.
Nice analysis Marc! The fix looks good to me.
|
/integrate Thanks all for reviews! |
|
Going to push as commit 1f0dfdb.
Your commit was automatically rebased without conflicts. |
|
@marc-chevalier Pushed as commit 1f0dfdb. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Did you know that ranges can be disjoints and yet not ordered?! Well, in modular arithmetic.
Let's look at a simplistic example:
With signed ranges, before the second
if,xis in[-1, 1]. Which is enough to enter to second if, but not enough to prove you have to enter it: it wrongly seems that after the secondifis still reachable. Twaddle!With unsigned ranges, at this point
xis in[1, 2^32-1], and then, it is clear thatx != 0. This information is used to refine the value ofxin the (missing) else-branch, and so, after the if. This is done with simple lattice meet (Hotspot's join): in the else-branch, the possible values ofxare the meet of what is was worth before, and the interval in the guard, that is[0, 0]. Thanks to the unsigned range, this is known to be empty (that is bottom, or Hotspot's top). And with a little reduced product, the whole type ofxis empty as well. Yet, this information is not used to kill control yet.This is here the center of the problem: we have a situation such as:


After node
110 CastIIis idealized, it is found to be Top, and then the uncommon trap at129is replaced by238 Haltby being value-dead.Since the control is not killed, the node stay there, eventually making some predicate-related assert fail as a trap is expected under a
ParsePredicate.And that's what this change proposes: when comparing integers with non-ordered ranges, let's see if the unsigned ranges overlap, by computing the meet. If the intersection is empty, then the values can't be equals, without being able to order them. This is new! Without unsigned information for signed integer, either they overlap, or we can order them. Adding modular arithmetic allows to have non-overlapping ranges that are also not ordered.
Let's also notice that 0 is special: it is important bounds are on each side of 0 (or 2^31, the other discontinuity). For instance if
xcan be 1 or 5, for instance, both the signed and unsigned range will agree on[1, 5]and not be able to prove it's, let's say, 3.What would there be other ways to treat this problem a bit more generally? The classic solution is not to use intervals all the time: allow small set of values, up to a fixed cardinal (for instance 5 or 10), after which we switch to a range. This is quite easy and handle many cases: it is not that common that it is important for a variable to be equal to one of 10 distinct values, but not anything else in between. A modulo domain would also work along with interval (with a reduced product), but for only two values, or specific cases. That is not very general. A donut domain can also be helpful, but it needs smart heuristic. For 2 points, there are two donuts: in the previous example
[1, 5]and[INT_MIN, INT_MAX] \ [2, 4], but only the second allows to prove 3 is not in. Having signed and unsigned range is somewhat having both donuts for some cases, and having just one when they agree.There is another underlying question: why do we need to have code both for meet (HS's join, to refine the value of
x), and for guarding (to know whether a branch is taken). A typical abstract interpreter would actually do that with just one step, using aGuardfunction that refines a abstract state given a condition to satisfy. The resulting state is whatever enters the branch, already refined. If the branch is impossible, then the state has an empty concretization. This happens typically when one variable (in a non-relational domain) has an empty value (bottom), then the whole abstract state is empty. It can then be optimized into skipping the whole branch. In Hotspot, there are some major differences:We could imagine another way of working, returning the refined value of each variable in a condition (using a side table or spamming Cast nodes), for a given
BoolNode, without holding the abstract domain by the hand too much. But of course, asking first "for which operators is the comparison non-empty", and then "give me the refined value of this variable for this given operator" leads to duplication of work.Thanks,
Marc
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26504/head:pull/26504$ git checkout pull/26504Update a local copy of the PR:
$ git checkout pull/26504$ git pull https://git.openjdk.org/jdk.git pull/26504/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26504View PR using the GUI difftool:
$ git pr show -t 26504Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26504.diff
Using Webrev
Link to Webrev Comment