RFR(S): 8244086: Following 8241492, strip mined loop may run extra iterations

Roland Westrelin rwestrel at redhat.com
Wed Apr 29 08:40:08 UTC 2020


https://bugs.openjdk.java.net/browse/JDK-8244086
http://cr.openjdk.java.net/~roland/8244086/webrev.00/

The number of iterations to execute in an inner loop of a strip mined
loop nest is:

min(LoopStripMiningIter, limit - iv) for stride > 0
min(LoopStripMiningIter, iv - limit) for stride < 0

Assuming stride > 0 for the rest of the discussion (a similar problem
exists for stride < 0):

With 8241492, I changed that computation to use an unsigned comparison
because limit - init can be greater that max_jint. This assumes that
limit is always greater that init but in some rare cases that doesn't
hold. The body should then be executed for only one iteration but the
computation of the number of iterations above causes it to run for
LoopStripMiningIter. The fix I propose is to change the computation to:

min_unsigned(LoopStripMiningIter, max(0, limit - iv)) for stride > 0
min_unsigned(LoopStripMiningIter, max(0, iv - limit)) for stride < 0

Roland.



More information about the hotspot-compiler-dev mailing list