RFC : Approach to handle Allocation Merges in C2 Scalar Replacement
Nils Eliasson
nils.eliasson at oracle.com
Fri Feb 11 09:38:42 UTC 2022
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