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

Vladimir Kozlov kvn at openjdk.org
Tue Jul 1 17:08:43 UTC 2025


On Tue, 1 Jul 2025 13:24:49 GMT, Saranya Natarajan <snatarajan at openjdk.org> wrote:

>> src/hotspot/share/opto/compile.cpp line 2533:
>> 
>>> 2531:   {
>>> 2532:     TracePhase tp(_t_macroExpand);
>>> 2533:     print_method(PHASE_BEFORE_MACRO_EXPANSION, 3);
>> 
>> Should we move it before `mex.expand_macro_nodes()` call?
>
> Moving this would break the assumption of needing a `BEFORE_MACRO_ELIMINATION` as explained in the above reply.  One way to go about this would be to include a `BEFORE_MACRO_ELIMINATION` phase and remove the `PHASE_BEFORE_MACRO_EXPANSION` phase as this is only place where it is used. Would this be a reasonable fix ?

So `MACRO_ELIMINATION` is subset of `MACRO_EXPANSION`

>> src/hotspot/share/opto/phasetype.hpp line 94:
>> 
>>> 92:   flags(AFTER_LOOP_OPTS,                "After Loop Optimizations") \
>>> 93:   flags(AFTER_MERGE_STORES,             "After Merge Stores") \
>>> 94:   flags(AFTER_MACRO_ELIMINATION_STEP,   "After Macro Elimination Step") \
>> 
>> What is the reason to not have `BEFORE_MACRO_ELIMINATION`?
>
> The two main reasons for not having a `BEFORE_MACRO_ELIMINATION` are as follows: 
> - There is a dump in line 2426 (`print_method(PHASE_ITER_GVN_AFTER_EA, 2)`)  before we call  `mexp.eliminate_macro_nodes`  which performs the functionality of having a  `BEFORE_MACRO_ELIMINATION` for phase dump. 
> - There is dump in line 2533 (`print_method(PHASE_BEFORE_MACRO_EXPANSION, 3)`) before eliminating macro nodes which performs the similar function.

ok

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25682#discussion_r2178120635
PR Review Comment: https://git.openjdk.org/jdk/pull/25682#discussion_r2178120168


More information about the hotspot-compiler-dev mailing list