RFR: 8333393: PhaseCFG::insert_anti_dependences can fail to raise LCAs and to add necessary anti-dependence edges [v13]
Daniel Lundén
dlunden at openjdk.org
Wed Feb 5 17:40:24 UTC 2025
On Wed, 5 Feb 2025 16:11:15 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Thanks for the comment @eme64 @chhagedorn! Happy to iterate, never hesitate to provide comments. I do recall we discussed these MergeMem/Phi swap idealizations offline last week.
>>
>> I think this looks very promising. Looking at the two rules you mention and applying them iteratively to our example
>>
>> 7 Phi(3 MergeMem(1:A, 2:L), 5 MergeMem(1:A, 4:L))
>>
>> I get
>>
>> 7 Phi(3 MergeMem(1:A, 2:L), 5 MergeMem(1:A, 4:L)) into
>> MergeMem(Phi:A(1:A, 5 MergeMem(1:A, 4:L)),
>> Phi:L(2:L, 5 MergeMem(1:A, 4:L))) into
>> MergeMem(MergeMem(Phi:A(1:A, 1:A), Phi:L(1:A, 4:L)),
>> Phi:L(2:L, 5 MergeMem(1:A, 4:L))) into
>> MergeMem(MergeMem(Phi:A(1:A, 1:A), Phi:L(1:A, 4:L)),
>> Phi:L(2:L, 4:L)))
>>
>> Then, after this, we should be able to merge the resulting `Phi:L(2:L, 4:L)` with 6 Phi (`initial_mem`). So, essentially, we have broken out the `L` part of `7 Phi` and realized it is the same as `6 Phi`. I guess this is what you are also saying?
>>
>> For EXAMPLE 2:
>>
>> 4 Phi(1:A, 3 MergeMem(1:A, 2:!L)) into
>> MergeMem(Phi(1:A, 1:A), Phi(1:A, 2:!L))
>>
>> `Phi(1:A, 1:A)` is `1:A` so then we have a Phi-free path from `1 MachProj` to `5 membar_release` as well!
>>
>> I'll have a look and see if I can figure out why we do not apply such idealizations here.
>
> That sounds about right, yes! Thanks for persisting here. I'm really looking forward to what you find 😊
Interestingly, this is the line in `cfgnode.cpp` that blocks the MergeMem/Phi swap idealization:
// This restriction is temporarily necessary to ensure termination:
if (!saw_self && adr_type() == TypePtr::BOTTOM) merge_width = 0;
If I comment out the line it solves all the failures we have seen. I double-checked that we then perform the exact MergeMem/Phi swap idealizations discussed above.
I am wondering what the proper solution is here. I will, of course, investigate if it is possible to loosen the restriction and still ensure termination. On the other hand, it also seems strange that the anti-dependence search is so sensitive to missing idealizations?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22852#discussion_r1943389830
More information about the hotspot-compiler-dev
mailing list