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

C2 should better optimize not-equal integer comparisons

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 15
    • 11, 12, 13, 14, 15
    • hotspot
    • b06

      C2 is currently not able to optimize checks like the following:

          public static void test1(boolean inc) {
              int i = 42;
              if (inc) {
                  i += 100;
              }
              // i: 42..142
              if (i != 42) {
                  // i: 43..142
                  if (i <= 42) {
                     throw new RuntimeException("Should not reach here");
                  }
              }
          }

      Since i can never be <= 42 in the inner branch, all code could be removed.

            thartmann Tobias Hartmann
            thartmann Tobias Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: