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

C2: Wrong execution with Integer.bitCount(int) instrinsic on AArch64

XMLWordPrintable

      There seems to be an issue with the Integer.bitCount(int) intrinsic on AArch64. Somehow, the input argument into the bitCount intrinsic ends up being cut which is propagated to the caller. Maybe some register corruption.

      To reproduce:

      $ java -Xbatch -XX:CompileOnly=Reduced::test Reduced.java
       
      Output:
      Exception in thread "main" java.lang.RuntimeException: Wrong result: 263219110
      at Reduced.main(Reduced.java:10)

      No exception with -Xint or on x64.

      ====================
      Original report:

      The attached Test.java file prints different output when compiled vs. when interpreted, on AArch64 only.

      $ java -Xint Test.java
      2166766936661037687
      -5936201357435948857
      -8914451713432026907
      -3053072614657754545
      -5400070531972085357
      3626172417624192429
      3415121120042614434
      2717387767676077548
      -2066234294734040154
      4482272172956477350

      $ java -Xbatch Test.java
      2166766936661037687
      -5936201357435948857
      -8914451713432026907
      -3053072614657754545
      -5400070531972085357
      3626172417624192429
      3415121120042614434
      2717387767676077548
      933614502
      263219110

      The last two lines differ. When running with -Xcomp, all lines of the output differ. The output on AMD64 is always the same as for the -Xint run, so I think this must be an AArch64-specific miscompilation.

      Observed with a 25-ea+15-LTS-1670 build.

        1. Reduced.java
          0.6 kB
          Christian Hagedorn
        2. Test.java
          0.8 kB
          Gergö Barany

            Unassigned Unassigned
            gbarany Gergö Barany
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: