RFR: 8342662: C2: Add new phase for backend-specific lowering [v6]

Xiaohong Gong xgong at openjdk.org
Tue Jan 14 06:50:41 UTC 2025


On Mon, 16 Dec 2024 02:23:30 GMT, Jasmine Karthikeyan <jkarthikeyan at openjdk.org> wrote:

>> Hi all,
>> This patch adds a new pass to consolidate lowering of complex backend-specific code patterns, such as `MacroLogicV` and the optimization proposed by #21244. Moving these optimizations to backend code can simplify shared code, while also making it easier to develop more in-depth optimizations. The linked bug has an example of a new optimization this could enable. The new phase does GVN to de-duplicate nodes and calls nodes' `Value()` method, but it does not call `Identity()` or `Ideal()` to avoid undoing any changes done during lowering. It also reuses the IGVN worklist to avoid needing to re-create the notification mechanism.
>> 
>> In this PR only the skeleton code for the pass is added, moving `MacroLogicV` to this system will be done separately in a future patch. Tier 1 tests pass on my linux x64 machine. Feedback on this patch would be greatly appreciated!
>
> Jasmine Karthikeyan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Implement apply_identity

src/hotspot/share/opto/phaseX.cpp line 2301:

> 2299:   // that may undo the changes done during lowering.
> 2300: 
> 2301:   return k->LoweredIdeal(this);

I'm sorry that I still cannot understand well what this method is expected to do for a node. For example, if we need to add some architecture specific optimization for `MulNode` like AArch64, we can add the lowering code in `lower_node_platform` for AArch64, right? Do we also need to override the `LoweredIdeal()` for `MulNode` ? Thanks!

src/hotspot/share/opto/phaseX.cpp line 2310:

> 2308: Node* PhaseLowering::lower_node(Node* n) {
> 2309:   // Apply shared lowering transforms
> 2310: 

Per my understanding, this is a backend specific lowering phase, is there any scenario that a platform in-dependent lowering is needed here? As we already have the common GVN phase for common node idealize, is there any difference for such shared transformations? Thanks!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21599#discussion_r1914323626
PR Review Comment: https://git.openjdk.org/jdk/pull/21599#discussion_r1914320271


More information about the hotspot-compiler-dev mailing list