RFR: 8342941: IGV: Add new graph dumps for post loop, empty loop removal, and one iteration removal

Christian Hagedorn chagedorn at openjdk.org
Thu Jun 12 06:20:27 UTC 2025


On Wed, 11 Jun 2025 13:54:20 GMT, Saranya Natarajan <snatarajan at openjdk.org> wrote:

> This changeset adds BEFORE/AFTER graph dumps for creating a post loop (`insert_post_loop()`), removing an empty loop (`do_remove_empty_loop()`), and removing a one iteration loop (`do_one_iteration_loop()`).
> 
> Changes:
> - Added `BEFORE_POST_LOOP` and `AFTER_POST_LOOP` for dumping graphs before and after `insert_post_loop()`.
> - Added `BEFORE_REMOVE_EMPTY_LOOP` and `AFTER_REMOVE_EMPTY_LOOP` for dumping graphs before and after `do_remove_empty_loop()`.
> - Added `BEFORE_ONE_ITERATION_LOOP` and `AFTER_ONE_ITERATION_LOOP` for dumping graphs before and after `do_one_iteration_loop()`.
> 
> Below are sample screenshots (IGV print level 4 ) mainly showing the new phase .
> 1. `BEFORE_POST_LOOP` and `AFTER_POST_LOOP` 
> ![image](https://github.com/user-attachments/assets/1661cede-5d70-4e0d-abec-3d091c7675c8)
> 2. `BEFORE_POST_LOOP` and `AFTER_POST_LOOP` with SuperWordLoopUnrollAnalysis enabled
> ![image](https://github.com/user-attachments/assets/6a22e6f0-4e6c-4e9d-8b6b-2bf75fac783d)
> 3.` BEFORE_REMOVE_EMPTY_LOOP `and `AFTER_REMOVE_EMPTY_LOOP`
> ![image](https://github.com/user-attachments/assets/3281f00b-575e-4604-83dd-831037d8dd47)
> 4. `BEFORE_ONE_ITERATION_LOOP` and `AFTER_ONE_ITERATION_LOOP`
> ![image](https://github.com/user-attachments/assets/efddbc9a-64f7-403d-acfe-330d75a00911)
> 
> Question to reviewers:
> Are the new compiler phases OK, or should we change anything?
> 
> 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))

Thanks for adding those!

You are currently dumping the `CountedLoop` for the "before" and "after" dump. I think we could improve the "after" dump to show the actual change:
- In the "after" dump of the post loop, we could dump the new post loop instead of the old one.
- For the empty loop removal we could dump the `final_iv` instead:
https://github.com/openjdk/jdk/blob/c5a1543ee3e68775f09ca29fb07efd9aebfdb33e/src/hotspot/share/opto/loopTransform.cpp#L3172
- For the one iteration removal, I'm not sure if it's worth to print anything. I think we can either print nothing or the init which replaces the iv:
https://github.com/openjdk/jdk/blob/c5a1543ee3e68775f09ca29fb07efd9aebfdb33e/src/hotspot/share/opto/loopTransform.cpp#L3334

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

Changes requested by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/25756#pullrequestreview-2919673432


More information about the hotspot-compiler-dev mailing list