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

Saranya Natarajan snatarajan at openjdk.org
Tue Jul 1 13:27:47 UTC 2025


On Mon, 30 Jun 2025 16:24:03 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Saranya Natarajan has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>> 
>>   merge with master
>>   Merge branch 'master' of https://git.openjdk.org/jdk into JDK-8325478
>
> 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 ?

> 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.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25682#discussion_r2177603003
PR Review Comment: https://git.openjdk.org/jdk/pull/25682#discussion_r2177602894


More information about the hotspot-compiler-dev mailing list