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

    • b14
    • x86, aarch64
    • Verified

        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)));
          }
        }

          1. Test.java
            0.4 kB
            Tobias Hartmann
          2. TestAll.java
            2 kB
            Tobias Hartmann
          3. TestAllFix.java
            3 kB
            Sandhya Viswanathan
          4. TestAllFloat.java
            2 kB
            Sandhya Viswanathan

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

                Created:
                Updated:
                Resolved: