RFR(XS): 8211451: ~2.5% regression on compression benchmark starting with 12-b11

Vladimir Kozlov vladimir.kozlov at oracle.com
Tue Oct 16 23:40:46 UTC 2018


On 10/16/18 8:44 AM, Roland Westrelin wrote:
> 
> Hi Vladimir,
> 
> Thanks for looking at this.
> 
>> I am not sure it is correct. You can go into infinite loop with
>> overflow with stride (> 1) which jump over the value you compare with.
> 
> For equality checks, stride = 1 (or -1).
> 
>    if (bt == BoolTest::eq || // Bail out, but this loop trips at most twice!
>        // Odd stride
>        (bt == BoolTest::ne && stride_con != 1 && stride_con != -1) ||
>        // Count down loop rolls through MAXINT
>        ((bt == BoolTest::le || bt == BoolTest::lt) && stride_con < 0) ||
>        // Count up loop rolls through MININT
>        ((bt == BoolTest::ge || bt == BoolTest::gt) && stride_con > 0)) {
>      return false; // Bail out
>    }

I forgot about these checks. So the only case which skip init_t check is 'ne' and abs(stride) == 1.

> 
> This is turning:
> 
> for (;;) {
>    if (i == limit) {
>      break;
>    }
>    i += stride;
> }
> 
> into:
> 
> for (;;) {
>    i += stride;
>    if (i == limit+stride) {
>      break;
>    }
> }
> 
> The test for equality is turned into an inequality check only if init <
> limit is known and stride == 1 (or a similar condition for stride =
> -1). In that case i += stride can't overflow.

Where this is done?

> 
> If the equality check is kept, i+stride can overflow only if init >
> limit and that would be an infinite loop anyway.

This argument does not hold. You are converting loop into counted loop for which loop optimizations 
assume that it is not infinite.

> 
> Roland.
> 


More information about the hotspot-compiler-dev mailing list