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

C2: Int >0 not recognized as !=0 for div by 0 check

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 13
    • Fix Version/s: 14
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b25

      Description

      C2 knows that the "int x" is not 0 at the division when using the check "x != 0" in the simple test program below.
      However, when using "x > 0", it generates an unnecessary zero check and an uncommon trap. I believe this is a bug. C2 should treat x as non-zero after having found the lower bound "x > 0".


      TestDiv.java:
      public class TestDiv{

        public static int test_method(int x) {
            if (x > 0) { // x != 0 helps C2, why not x > 0?
                return 3 % x;
            }
            return 0;
        }

        public static void main(String args[]) {
          int result = test_method(3);
          System.out.println("result: " + result);
        }
      }

      Command line:
      jdk-jdk-fastdebug/images/jdk/bin/java -XX:+PrintOptoAssembly -XX:-TieredCompilation -XX:CompileCommand=compileonly,TestDiv::test_method -Xcomp TestDiv

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              phedlin Patric Hedlin
              Reporter:
              mdoerr Martin Doerr
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: