Skip to content
Commit ea652eac authored by xueliang.zhong's avatar xueliang.zhong Committed by Xueliang Zhong
Browse files

Quiet SNaN inputs in Half.toFloat()

This CL fixes Half.toFloat() in handling SNaN inputs,
to make sure the Java implementation has same semantics
as the hardware implementations (Arm and Intel).

1. Armv8.2 implementation (FCVT):
  // tested as ART intrinsic on Pixel3
  __ Fmov(h31, w1);  // input: w1 register
  __ Fcvt(s0, h31);  // output: s0 register

2. X86 implementation (VCVTPH2PS):
  // clang -mf16c test.c
  float x86_toFloat(short h) {
    __v8hi v = {h, 0, 0, 0, 0, 0, 0, 0};
    __v4sf r = __builtin_ia32_vcvtph2ps(v);
    return r[0];
  }

3. Java implementation (software):
  android.util.Half.toFloat(short);

Test: Exhaustive testing of 0x0..0xFFFF input bits on above three
      implementations and compare output values.

Change-Id: Iff137858379bf43e59cde94c9d19c2054a3d4f93
parent 17f9b9bf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment