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

Missed dead code elimination in C2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 23.0.2
    • hotspot
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      # Java version
      java 23.0.2 2025-01-21
      Java(TM) SE Runtime Environment (build 23.0.2+7-58)
      Java HotSpot(TM) 64-Bit Server VM (build 23.0.2+7-58, mixed mode, sharing)

      java 21.0.6 2025-01-21 LTS
      Java(TM) SE Runtime Environment (build 21.0.6+8-LTS-188)
      Java HotSpot(TM) 64-Bit Server VM (build 21.0.6+8-LTS-188, mixed mode, sharing)

      # OS
      Ubuntu 20.04.6 LTS

      A DESCRIPTION OF THE PROBLEM :
      Missed dead code elimination for Math.log leading to long execution time

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the code provided below and run it with different JVMs/options

      ACTUAL -
      ```
      # JDK 23.0.2 C1
      time java -XX:TieredStopAtLevel=1 Test 3.93s user 0.02s system 100% cpu 3.942 total
      # JDK 23.0.2 C2
      time java Test 64.03s user 0.03s system 100% cpu 1:04.04 total
      # GraalVM 23.0.2
      time java Test 0.11s user 0.05s system 188% cpu 0.084 total
      ```

      ---------- BEGIN SOURCE ----------
      # Test.java
      ```java
      public class Test {
          public static int m() {
              double a = -4.0;
              double b = 0.79;
              for (int i = 0; i < 100000; i++) {
                  double d = Math.log(b);
                  if (d != a) {
                  }
              }
              return 1;
          }

          public static void main(String[] strArr) {
              int blackhole = 0;
              for (int i = 0; i < 100000; i++) {
                  blackhole += m();
              }
              System.out.println("blackhole = " + blackhole);
          }
      }
      ```
      ---------- END SOURCE ----------

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

              Created:
              Updated:
              Resolved: