RFR: 8280799: С2: assert(false) failed: cyclic dependency prevents range check elimination

Roland Westrelin roland at openjdk.java.net
Wed Feb 2 10:44:28 UTC 2022


The loop exit condition of the test method:

if (i == stop) {
    break;
}

requires insertion of a loop limit predicate when the loop is turned
into a counted loop. stop is a LoadI. Next:

array[stop - i + j] = 0;

is transformed to:

array[stop - i] = 0;

and the range check for that array access becomes candidate for
predication in a subsequent loop opts pass. stop has control just
above the loop limit check when that happens (because it is assigned
control as late as possible). But the loop predicate for the bound
check needs to be above the loop limit check and that causes the
assert failure.

There's already logic in PhaseIdealLoop::build_loop_late_post_work()
to assign control to nodes above predicates so this sort of issues
doesn't occur. But it only applies to node initially on the entry
projection right above the loop head. The fix I propose is to remove
that restriction.

That logic was added by JDK-8203197 and looking back at this change I
noticed I replaced some existing logic with the current logic but,
while the 2 overlap, the current logic is not guaranteed to always
cover some cases handled by the old logic. So I resurrected that old
logic here.

Finally, when running tests, I hit failures because Opaque nodes for
skeleton predicates can now end up above a predicate that is split
thru phi. That causes the Opaque nodes to be split up and breaks
pattern matching. I'm actually not sure this issue is specific to the
change here so I think it's best to treat it as a general issue and
fix it by cloning the chain of nodes that lead to the Opaque node
down.

-------------

Commit messages:
 - fix & test

Changes: https://git.openjdk.java.net/jdk/pull/7319/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7319&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8280799
  Stats: 341 lines in 3 files changed: 315 ins; 21 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7319.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7319/head:pull/7319

PR: https://git.openjdk.java.net/jdk/pull/7319


More information about the hotspot-compiler-dev mailing list