RFR: 8333334: C2: Make result of `Node::dominates` more precise to enhance scalar replacement [v8]
Christian Hagedorn
chagedorn at openjdk.org
Thu Aug 22 09:31:08 UTC 2024
On Thu, 22 Aug 2024 09:02:47 GMT, Qizheng Xing <qxing at openjdk.org> wrote:
>> This patch changes the algorithm of `Node::dominates` to make the result more precise, and allows the iterators of `ConcurrentHashMap` to be scalar replaced.
>>
>> The previous algorithm will return a conservative result when encountering a dead control flow, and only try the first two input paths of a multi-input Region node, which may prevent the scalar replacement in some cases.
>>
>> For example, with G1 GC enabled, C2 generates GC barriers for `ConcurrentHashMap` iteration operations at some early phases, and then eliminates them in a later IGVN, but `LoadNode` is also idealized in the same IGVN. This causes `LoadNode::Ideal` to see some dead barrier control flows, and refuse to split some instance field loads through Phi due to the conservative result of `Node::dominates`, and thus the scalar replacement can not be applied to iterators in the later macro elimination phase.
>>
>> This patch allows `Node::dominates` to try other paths of the last multi-input Region node when the first path is dead, and makes `ConcurrentHashMap` iteration ~30% faster:
>>
>>
>> Benchmark (nkeys) Mode Cnt Score Error Units
>> Maps.testConcurrentHashMapIterators 10000 avgt 15 414099.085 ± 33230.945 ns/op # baseline
>> Maps.testConcurrentHashMapIterators 10000 avgt 15 315490.281 ± 3037.056 ns/op # patch
>>
>>
>> Testing: tier1-4.
>
> Qizheng Xing has updated the pull request incrementally with four additional commits since the last revision:
>
> - Add wrapper method for checking `DomResult` of `all_controls_dominate`.
> - Remove redundant `applyIf` and fix style for IR test.
> - Fix style.
> - Add brackets around modified if/else branches.
Otherwise, the update looks good, thanks!
src/hotspot/share/opto/memnode.cpp line 1717:
> 1715: // Wait for the dead code to be removed.
> 1716: // The dead code will eventually be removed in IGVN,
> 1717: // so we have an unambiguous result whether it's dominated or not.
Suggestion:
// There is some dead code which eventually will be removed in IGVN. Once this is the case, we get an unambiguous
// dominance result. Push the node to the worklist again until the dead code is removed.
-------------
Marked as reviewed by chagedorn (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/19496#pullrequestreview-2253980782
PR Review Comment: https://git.openjdk.org/jdk/pull/19496#discussion_r1726697616
More information about the hotspot-compiler-dev
mailing list