JDK-8236721 : C2 should better optimize not-equal integer comparisons
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,12,13,14,15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-01-07
  • Updated: 2020-01-22
  • Resolved: 2020-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b06Fixed
Related Reports
Relates :  
Description
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.
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/9c53fdf6ba63 User: thartmann Date: 2020-01-15 07:45:19 +0000
15-01-2020

http://cr.openjdk.java.net/~thartmann/8236721/webrev.00/
07-01-2020