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

C2 Intrinsification of Float.floatToFloat16 and Float.float16ToFloat Yields Different Result than the Interpreter

    XMLWordPrintable

Details

    • b14
    • x86, aarch64
    • Verified

    Backports

      Description

        The following code snippet prints twice 31745 with the interpreter, and 32257 31745 with -Xcomp -XX:-TieredCompilation. This means, C2 will eliminate both intrinsifications if they are within the same compilation unit (the latter print), and return the same result as the interpreter. But if it applies the intrinsifications respectively in different compilation units and employ the underlying vcvtps2ph and vcvtph2ps instructions (the former print), then it will return a different value.


        public class Foo {
          public static short bar(float f) {
            return Float.floatToFloat16(f);
          }
          public static void main(String[] args) {
            System.out.println(bar(Float.float16ToFloat((short) 31745)));
            System.out.println(Float.floatToFloat16(Float.float16ToFloat((short) 31745)));
          }
        }

        Attachments

          1. Test.java
            0.4 kB
          2. TestAll.java
            2 kB
          3. TestAllFix.java
            3 kB
          4. TestAllFloat.java
            2 kB

          Issue Links

            Activity

              People

                kvn Vladimir Kozlov
                yzheng Yudi Zheng
                Votes:
                0 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: