RFR(L): 8186027: C2: loop strip mining

Roland Westrelin rwestrel at redhat.com
Wed Oct 25 14:29:03 UTC 2017

Hi Vladimir,

Thanks for looking at this.

> Did you consider less intrusive approach by adding branch over
> SafePoint with masking on index variable?
>    int mask = LoopStripMiningMask * inc; // simplified
>    for (int i = start; i < stop; i += inc) {
>       // body
>       if (i & mask != 0) continue;
>       safepoint;
>    }
> Or may be doing it inside .ad file in new SafePoint node
> implementation so that ideal graph is not affected.

We're looking for the best trade off between latency and thoughput: we
want the safepoint poll overhead to be entirely eliminated even when the
safepoint doesn't trigger.

> I am concern that suggested changes may affect Range Check elimination
> (you changed limit to variable value/flag) in addition to complexity
> of changes which may affect stability of C2.

The CountedLoop that is created with my patch is strictly identical to
the CountedLoop created today with -UseCountedLoopSafepoints. Bounds are
not changed at that time. They are left as they are today. The
difference, with loop strip mining, is that the counted loop has a
skeleton outer loop. The bounds of the counted loop are adjusted once
loop opts are over. If the counted loop has a predicate, the predicate
is moved out of loop just as it is today. The only difference with
today, is that the predicate should be moved out of the outer loop. If a
pre and post loop needs to be created, then the only difference with
today is that the clones need to be moved out of the outer loop and
logic that locate the pre from the main loop need to account for the
outer loop.

It's obviously a complex change so if your primary concern is stability
then loop strip mining can be disabled by default. Assuming strip mining
off, then that patch is mostly some code refactoring and some logic that
never triggers.


More information about the hotspot-compiler-dev mailing list