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

Support AVX10 saturating floating point conversion instructions

XMLWordPrintable

    • x86_64
    • generic

      Currently, floating point to integral conversion requires special handling to support NaN and +/- Infinity.

       * If src is NaN, the result is 0.
       * If the src is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE,
       * The result is equal to the value of Integer.MIN_VALUE.
       * If the src is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE,
       * The result is equal to the value of Integer.MAX_VALUE.

      AVX10.2 adds new staturing conversion instructions "vcvttss2sis", "vcvttsd2sis", "vcvttps2dqs", "vcvttpd2qqs" which directly comply with Java and IEEE 754 semantics.


      #include <stdio.h>
      #include <math.h>

      // compile command : clang -mavx10.2-256 -DAVX10 saturating-f2i.
      // emulation command line : sde -dmr -itrace-execute-emulate -icount -ptr_raise -- ./a.out
      // tags : arm parity, optimization over legacy CVTTSS2SI + SPECIAL-HANDLING.

      void micro_f2i_sat_new(float src) {
        int dst = 0;
        asm volatile (
            "vcvttss2sis %1, %0 \n\t"
          : "=r"(dst)
          : "x"(src)
          :
        );
        printf("src = %f , dst = %d\n", src, dst);
      }
      int main() {
        printf("F2I SATURATING NEW\n");
        micro_f2i_sat_new(10.2f);
        micro_f2i_sat_new(INFINITY);
        micro_f2i_sat_new(-INFINITY);
        micro_f2i_sat_new(0x1.fffp+35f);
        micro_f2i_sat_new(0.0f);
        micro_f2i_sat_new(-0.0f);
        micro_f2i_sat_new(NAN);
        return 0;
      }

            missa Mohamed Issa
            jbhateja Jatin Bhateja
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: