-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8292088: C2: assert(is_OuterStripMinedLoop()) failed: invalid node class: IfTrue #10306
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
👋 Welcome back chagedorn! A progress list of the required criteria for merging this PR into |
@chhagedorn 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. |
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.
Makes sense to me. |
@chhagedorn 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 62 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 |
Thanks Roland for your review and your feedback to further investigate the removal of |
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.
Thanks Vladimir for your review! /integrate |
Going to push as commit 471e2f1.
Your commit was automatically rebased without conflicts. |
@chhagedorn Pushed as commit 471e2f1. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
In
testKnownLimit()
, we directly use the (pre-incremented) iv phiIV_PHI_i
(232 Phi
) in the loop exit check of thewhile
loop:Such pre-incremented iv phi uses after the loop are detected in
PhaseIdealLoop::reorg_offsets()
and replaced in order to reduce register pressure. We insert an additionalOpaque2
node to prevent any optimizations to undo the effect ofPhaseIdealLoop::reorg_offsets()
:In the test case, this is done before CCP and looks like this:
At that point, we do not know yet that the
while
loop is only gonna be executed once (i.e.422 CountedLoopEnd
is always false). This only becomes known after CCP where the type of232 Phi
improves. But since we have anOpaque2
node, this update is not propagated until theOpaque2
nodes are removed in macro expansion:jdk/src/hotspot/share/opto/macro.cpp
Lines 2412 to 2414 in 11e7d53
During macro expansion, we also adjust the strip mined loop: We move the
421 Bool
of the inner loop exit check422 CountedLoopEnd
to the outer strip mined loop exit check and adjust the inner loop exit check in such a way that C2 cannot figure out that the entire loop is only run once. In the next IGVN phase, the outer strip mined loop node is removed while the inner loop429 CountedLoop
is not.Later in
verify_strip_mined()
, we cannot find the outer strip mined loop of429 CountedLoop
anymore and we fail with the assertion.The first thought to fix this problem is to add
Opaque2::Value()
to let type information flow. But this does not fix the problem completely if the type of the iv phi has no known upper limit. There we have the problem that in generaltype(phi) != type(phi + x - x)
becausephi + x
could overflow and we end up with typeint
(which happens intestUnknownLimit()
).I therefore suggest to remove
Opaque2
nodes earlier before macro expansion to fix this bug. A good place seems to be right after loop opts are over. We can remove them at the same time asOpaque1
nodes by adding a similarIdentity()
method. This lets the loop nodes to be folded away before trying to adjust the outer strip mined loop limit.Are Opaque2 nodes really useful?
When working on this bug, I started to question the usage of
Opaque2
nodes in general. We are still running IGVN afterOpaque2
nodes are currently removed. This simply undoes the effects ofPhaseIdealLoop::reorg_offsets()
again and we end up using pre-incremented iv phis anyways. My theory was that we are either blocking some specific optimizations during loop opts which cannot be reverted later in IGVN or that we initially (when thisOpaque2
optimization was added) did not run IGVN anymore onceOpaque2
nodes are removed.I could not think of any such non-revertable optimization that
Opaque2
nodes could prevent. On top of that,PhaseIdealLoop::reorg_offsets()
also does not mention anything alike. I therefore had a look at the history ofOpaque2
nodes. Unfortunately, they were added before the initial load commit. I've dug deeper through some old closed repo and found that at the time theOpaque2
nodes were introduced around 20 years ago, we did not do any IGVN anymore after the removal of theOpaque2
nodes - and we generated code with these unoptimizediv phi + x - x
patterns.This suggests that today the
Opaque2
nodes are indeed not really doing what they were originally supposed to do. I would therefore suggest to investigate their complete removal in a separate RFE and go with the suggested fix above which does not make the current situation of the questionableOpaque2
node usages any worse.Thanks,
Christian
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10306/head:pull/10306
$ git checkout pull/10306
Update a local copy of the PR:
$ git checkout pull/10306
$ git pull https://git.openjdk.org/jdk pull/10306/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10306
View PR using the GUI difftool:
$ git pr show -t 10306
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10306.diff