RFR: 8333393: PhaseCFG::insert_anti_dependences can fail to raise LCAs and to add necessary anti-dependence edges [v10]

Daniel Lundén dlunden at openjdk.org
Thu Jan 30 13:19:51 UTC 2025


On Thu, 30 Jan 2025 11:32:52 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

> I see you are assuming that `initial_mem` can only be killed before it is merged in B2

Can you elaborate a bit here? I'm probably misunderstanding you, but I would say that the memory alias category we load (part of `initial_mem` and also part of all the additional search roots) can get killed at earliest in the `early` block. For example, in EXAMPLE 2 in the source code comments, `5 membar_release` kills all of memory, and in particular the memory for the load's alias category represented simultaneously by `1 MachProj` and `4 Phi`. They both represent the load's memory because `2 Store` and `3 MergeMem` only modifies/kills other parts of memory (irrelevant for the load).

> 
> ```
> mem m1;
> mem m2;
> if (condition) {
> } else {
> }
> mem m = Phi(m1, m2);
> kill m1;
> ```

Given that you merge the `if`-`else` control-flow at the `Phi` here, shouldn't the definition of at least one of `m1` and `m2` occur within one of the branches? Similarly for your second larger example.


mem m1;
if (condition) {
} else {
  mem m2; // The parts of m2 relevant for our load are equal to m1
}
mem m = Phi(m1, m2); // The relevant memory for the load is still the same in m1 and m
// We must schedule the load before kills to both m1 and m
kill m1;


Modifying your example slightly, the above is basically EXAMPLE 2 in the source code.

> This kill will also kill `m4`, **what is the invariant you think will hold that prevents this situation**, we have seen in your first example that `107 Phi` and `119 Phi` contain the same memory slice and live at the same block, **what if `119 Phi` is in an earlier block? Or is there anything that will prevent it from happening?**

`initial_mem` is always the earliest possible memory definition for the load, which means all additional search roots must occur later or at the same time as `initial_mem`. For example, `119 Phi` occurs at the same time as `107 Phi`/`initial_mem`. This is items 2 and 3 in the definition (lines 870-871).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22852#issuecomment-2624493184


More information about the hotspot-compiler-dev mailing list