[External] : Re: What is the purpose of loop predication lower bounds check
Vladimir Kozlov
vladimir.kozlov at oracle.com
Thu Feb 1 20:02:15 UTC 2024
In general we usually generate different checks during parsing and
optimize/collapse/remove/merge them later based on full information
after parsing.
On 2/1/24 11:55 AM, Vladimir Kozlov wrote:
> If array is external it could be 0 sized.
> With locally allocated array the check should collapse unless we missing
> such optimization.
>
> On 2/1/24 11:52 AM, Cao, Joshua wrote:
>> If I use the same example but with negative stride:
>>
>>
>> ```
>>
>> for (int i = iters - 1; i >= 0; --i) {
>>
>> blackhole(data[i]);
>>
>> }
>> ```
>>
>> We still generate these two checks:
>> ```
>>
>> if (data.length <= 0) { trap() }
>> if (data.length <= iters - 1) { trap() }
>>
>> ```
>>
>>
>> So even with negative stride, the upper bounds check is sufficient by
>> itself.
>>
>>
>> I am playing around with stride/scale/offset and I cannot come up with an
>>
>> example where the lower bounds check is important.
>>
>> ------------------------------------------------------------------------
>> *From:* hotspot-compiler-dev <hotspot-compiler-dev-retn at openjdk.org>
>> on behalf of Vladimir Kozlov <vladimir.kozlov at oracle.com>
>> *Sent:* Thursday, February 1, 2024 11:44:29 AM
>> *To:* hotspot-compiler-dev at openjdk.org
>> *Subject:* RE: [EXTERNAL] What is the purpose of loop predication
>> lower bounds check
>> CAUTION: This email originated from outside of the organization. Do
>> not click links or open attachments unless you can confirm the sender
>> and know the content is safe.
>>
>>
>>
>> Initial index value is variable.
>>
>> Reverse (negative stride) processing of array?
>>
>> On 2/1/24 11:31 AM, Cao, Joshua wrote:
>>> Can I get some help with https://bugs.openjdk.org/browse/JDK-8325146?
>> <https://bugs.openjdk.org/browse/JDK-8325146?>
>>> What is
>>> the purpose of the lower bounds check for loop predication? It seems
>>> like an
>>> unnecessary if-check for any example I can come up with.
>>>
>>> Whatever the reason might be, I think there are cases in which we can
>>> ellide
>>> the lower bounds check, like in the example in the JBS issue.
>>>
>>>
More information about the hotspot-compiler-dev
mailing list