RFR(M): 8223051: support loops with long (64b) trip counts
Roland Westrelin
rwestrel at redhat.com
Mon Jun 22 12:47:10 UTC 2020
> I'm seeing some failures with -XX:StressLongCountedLoop=429496729. Will follow-up offline.
The last patch is flawed: predicates in the inner loop use the jvm state
from the predicates of the initial loop, that is the state before the
loop. If deoptimization happens for an inner loop predicate on an
iteration of the outer loop that's not the first one then execution
resumes as if the initial loop was never executed when it's already part
way through.
To fix this, I changed the code so one iteration of the loop is peeled
when the loop is transformed to a long counted loop. State for
predicates is obtained from the safepoint at the end of the peeled
iteration of the loop.
I removed some logic that causes safepoint to be eliminated if redundant
with a call so PhaseIdealLoop::is_long_counted_loop() has a better
chance of finding a safepoint where it needs one. Still, it's possible
that the safepoint is not right above the loop exit test in which case,
the transformation looks for a safepoint that dominates the backedge and
verifies that there's no side effects between the backedge and the
safepoint. In case of side effects, the transformation proceeds but the
inner loop will have no predicates (from some stress testing with CTW
this seems to happen only a handful of case).
This also requires the loop to be transformed in 2 passes of loop
optimizations: first the loop is transformed to a loop nest with 2 loops
and on the next loop pass, the inner loop becomes a counted loop. The
previous patch could backtrack in case the transformation to counted
loop fails. The previous patch would also not duplicate all tests that
PhaseIdealLoop::is_counted_loop() performs in
PhaseIdealLoop::is_long_counted_loop() to avoid some
complexity. PhaseIdealLoop::is_long_counted_loop() has to now follow
PhaseIdealLoop::is_counted_loop() striclty. That stricter requirement
also caught some bugs where PhaseIdealLoop::is_counted_loop() would fail
when it shouldn't have.
http://cr.openjdk.java.net/~roland/8223051/webrev.03/
diff from previous patch:
http://cr.openjdk.java.net/~roland/8223051/webrev.02-03/
Roland.
More information about the hotspot-compiler-dev
mailing list