RFR: 8274145: C2: Incorrect computation after JDK-8269752
Roland Westrelin
roland at openjdk.java.net
Thu Sep 30 13:07:32 UTC 2021
On Tue, 28 Sep 2021 22:58:30 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
>> The bug happens because an If node that follows a CountedLoop is
>> replaced by the CountedLoopEnd node of the main loop. Further
>> unrolling happens after the If is replaced which causes the condition
>> of the CountedLoopEnd node to change. This is made possible by
>> JDK-8269752. The fix I propose is to detect that corner case and
>> prevent the If to be replaced in that case.
>
> src/hotspot/share/opto/loopopts.cpp line 1396:
>
>> 1394: while (dom != cutoff) {
>> 1395: if (dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom &&
>> 1396: safe_for_if_replacement(dom)) {
>
> We skip replacement for counted loop but we still continue searching IDOMs. Which may find another dominating test before loop and replace node's control which may be not correct since we skipped loop with the same test.
> And you said "The fix I propose is to detect that corner case and
> prevent the If to be replaced in that case." We should bailout then.
Hi Vladimir. Thanks for reviewing this.
I'm not sure I understand. If dom is a CountedLoopEnd and dom->in(1) == bol then that test depends on the iv Phi so cutoff is the CountedLoop node and that code is not going to move above the loop.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5712
More information about the hotspot-compiler-dev
mailing list