RFR: 8333393: PhaseCFG::insert_anti_dependences can fail to raise LCAs and to add necessary anti-dependence edges [v12]
Christian Hagedorn
chagedorn at openjdk.org
Tue Feb 4 10:26:18 UTC 2025
On Fri, 31 Jan 2025 14:02:51 GMT, Daniel Lundén <dlunden at openjdk.org> wrote:
>> When searching for load anti dependences in GCM, it is not always sufficient to just search starting at the direct initial memory input to the load. Specifically, there are cases when we must also search for anti dependences starting at relevant Phi memory nodes in between the load's early block and the initial memory input's block. Here, "in between" refers to blocks in the dominator tree in between the early and initial memory blocks.
>>
>> #### Example 1
>>
>> Consider the ideal graph below. The initial memory for 183 loadI is 107 Phi and there is an important anti dependency for node 64 membar_release. To discover this anti dependency, we must rather search from 119 Phi which contains overlapping memory slices with 107 Phi. Looking at the ideal graph block view, we see that both 107 Phi and 119 Phi are in the initial memory block (B7) and thus dominate the early block (B20). If we only search from 107 Phi, we fail to add the anti dependency to 64 membar_release and do not force the load to schedule before 64 membar_release as we should. In the block view, we see that the load is actually scheduled in B24 _after_ a number of anti-dependent stores, the first of which is in block B20 (corresponding to the anti dependency on 64 membar_release). The result is the failure we see in this issue (we load the wrong value).
>>
>> 
>> 
>>
>> #### Example 2
>>
>> There are also situations when we need to start searching from Phis that are strictly in between the initial memory block and early block. Consider the ideal graph below. The initial memory for 100 loadI is 18 MachProj, but we also need to search from 76 Phi to find that we must raise the LCA to the last block on the path between 76 Phi and 75 Phi: B9 (= the load's early block). If we do not search from 76 Phi, the load is again likely scheduled too late (in B11 in the example) after anti-dependent stores (the first of which corresponds to 58 membar_release in B10). Note that the block B6 for 76 Phi is strictly dominated by the initial memory block B2 and also strictly dominates the early block B9.
>>
>> 
>> 
>>
>> ### Cha...
>
> Daniel Lundén has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 13 additional commits since the last revision:
>
> - Merge remote-tracking branch 'upstream/master' into insert-anti-dependences-8333393
> - Reorganize after comments from review
> - Rewording of semantics
> - Clarifications after comments from Roberto
> - Update src/hotspot/share/opto/gcm.cpp
>
> Co-authored-by: Roberto Castañeda Lozano <robcasloz at users.noreply.github.com>
> - Minor comment updates
> - Add more documentation of the change (with examples) in comments
> - Add example in comment
> - Fix comma splice in comment
> - Update after comments
> - ... and 3 more: https://git.openjdk.org/jdk/compare/390c70b4...e5f928cc
Nice summary in the code comments! I agree with the proposed point fix solution and revisit this again later.
test/hotspot/jtreg/compiler/codegen/TestGCMLoadPlacement.java line 2:
> 1: /*
> 2: * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
Since you opened the PR in the old year, you can probably just append 2025 here as well instead of replacing it.
Suggestion:
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
-------------
Marked as reviewed by chagedorn (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/22852#pullrequestreview-2592367987
PR Review Comment: https://git.openjdk.org/jdk/pull/22852#discussion_r1940893380
More information about the hotspot-compiler-dev
mailing list