RFC : Approach to handle Allocation Merges in C2 Scalar Replacement
Vladimir Kozlov
vladimir.kozlov at oracle.com
Fri Feb 11 18:01:06 UTC 2022
We can't do that unless we know that p0 does not escape in call() (we do such analysis in EA code already).
Otherwise there could be concurrent p0's fields updates.
Thanks,
Vladimir K
On 2/11/22 1:38 AM, Nils Eliasson wrote:
> This is also useful if only one of the paths are a local allocation. We must just be sure that the original phi actually
> can be removed.
>
> public int ex1(boolean cond, int first, int second) {
>
> p0 = call(...)
>
> if (cond) {
> p1 = Allocate(...);
> ...
> p1.x = second;
> p1.y = first;
> }
>
> p = phi(p0, p1) // unused and will be removed
>
>
> return phi(p0.x,p1.x) - phi(p0.y, p1.y);
> }
>
> Regards,
> Nils
>
> On 2022-02-11 05:07, Vladimir Kozlov wrote:
>> For this simple case we can teach C2's IGVN to split fields loads through Phi so that phi(p0, p1) is not used and
>> allocations as well. We can do that because we know that allocations and phi do not escape.
>>
>> public int ex1(boolean cond, int first, int second) {
>> p0 = Allocate(...);
>> ...
>> p0.x = first;
>> p0.y = second;
>>
>> if (cond) {
>> p1 = Allocate(...);
>> ...
>> p1.x = second;
>> p1.y = first;
>> }
>>
>> p = phi(p0, p1) // unused and will be removed
>>
>>
>> return phi(p0.x,p1.x) - phi(p0.y, p1.y);
>> }
>>
>> Thanks,
>> Vladimir K
>
More information about the hotspot-compiler-dev
mailing list