RFR: 8325478: Restructure the macro expansion compiler phase to not include macro elimination [v4]

Daniel Lundén dlunden at openjdk.org
Wed Jun 18 16:19:31 UTC 2025


On Tue, 17 Jun 2025 14:06:11 GMT, Saranya Natarajan <snatarajan at openjdk.org> wrote:

>> This changeset restructures the macro expansion phase to not include macro elimination and also adds a flag StressMacroElimination which randomizes macro elimination ordering for stress testing purposes.
>> 
>> Changes:
>> - Implemented a method `eliminate_opaque_looplimit_macro_nodes` that removes the functionality for eliminating Opaque and LoopLimit nodes from the `expand_macro_nodes ` method. 
>> - Introduced compiler phases` PHASE_AFTER_MACRO_ELIMINATION` 
>> -  Added a new Ideal phase for individual macro elimination steps. 
>> - Implemented the flag `StressMacroElimination`. Added functionality tests for `StressMacroElimination`, similar to previous stress flag `StressMacroExpansion` ([JDK-8317349](https://bugs.openjdk.org/browse/JDK-8317349)).
>> 
>> Below is a sample screenshot (IGV print level 4 ) mainly showing the new phase .
>> ![image](https://github.com/user-attachments/assets/16013cd4-6ec6-4939-ac66-33bb03d59cd6)
>> 
>> Questions to reviewers: 
>> - Is the new macro elimination phase OK, or should we change anything?
>> - In `compile.cpp `, `PHASE_ITER_GVN_AFTER_ELIMINATION` follows `PHASE_AFTER_MACRO_ELIMINATION` in the current fix. Should `PHASE_ITER_GVN_AFTER_ELIMINATION` be removed ? 
>> 
>> Testing:
>> GitHub Actions
>> tier1 to tier5 on windows-x64, linux-x64, linux-aarch64, macosx-x64, and macosx-aarch64.
>> Tested that thousands of graphs are correctly opened and visualized with IGV using the same test used in  ([JDK-8317349](https://bugs.openjdk.org/browse/JDK-8317349))
>
> Saranya Natarajan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update to IGV README based on review comment

Changes requested by dlunden (Committer).

src/hotspot/share/opto/compile.cpp line 2535:

> 2533:     print_method(PHASE_BEFORE_MACRO_EXPANSION, 3);
> 2534:     PhaseMacroExpand  mex(igvn);
> 2535:     // Do not allow new macro nodes once we started to expand

Suggestion:

    // Do not allow new macro nodes once we start to eliminate and expand

I know you just moved this comment, but i think it's worth clarifying while we're at it.

src/hotspot/share/opto/macro.cpp line 2467:

> 2465:     }
> 2466:   }
> 2467:   #ifndef PRODUCT

Suggestion:

#ifndef PRODUCT

test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java line 106:

> 104:     AFTER_MACRO_EXPANSION(          "After Macro Expansion"),
> 105:     AFTER_MACRO_ELIMINATION_STEP(   "After Macro Elimination Step"),
> 106:     AFTER_MACRO_ELIMINATION(        "After Macro Elimination"),

Suggestion: Move the two elimination phases before `BEFORE_MACRO_EXPANSION` for consistency with `phasetype.hpp`

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

PR Review: https://git.openjdk.org/jdk/pull/25682#pullrequestreview-2939868711
PR Review Comment: https://git.openjdk.org/jdk/pull/25682#discussion_r2155000680
PR Review Comment: https://git.openjdk.org/jdk/pull/25682#discussion_r2155001766
PR Review Comment: https://git.openjdk.org/jdk/pull/25682#discussion_r2155017333


More information about the hotspot-compiler-dev mailing list