Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8360135

Missing Dead Code Elimination for Empty Loop Optimization

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      wsl2-ubuntu 22.04
      Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

      java 21.0.7 2025-04-15 LTS
      Java(TM) SE Runtime Environment (build 21.0.7+8-LTS-245)
      Java HotSpot(TM) 64-Bit Server VM (build 21.0.7+8-LTS-245, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      The following test program including a empty loop, and it should exit quickly. However, it runs for a long time.

      When using OpenJ9, the loop will be optimized and exit quickly.

      Is it missing optimization for empty loop?

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Using JDK 21, run the following command:
      ```
      javac Test.java
      java Test
      ```

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The program should exit quickly, as the code in the loop is dead.
      ACTUAL -
      The program runs for a long time.

      ---------- BEGIN SOURCE ----------
      public class Test {
          public static void main(String[] args) {
              for (long i = 0; i < 1000000000000L; i++) {
                  // Dead code
              }
          }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: