[libc-commits] [libc] [libc][math][c23] Add hypotf16 function (PR #131991)

via libc-commits libc-commits at lists.llvm.org
Wed Mar 26 07:31:16 PDT 2025


lntue wrote:

I've got the following warnings when building the tests.  Can you add explicit casts for them?
```
[12/19] Building CXX object projects/libc/test/src/math/exhaustive/C...t.src.math.exhaustive.hypotf16_test.__unit__.dir/hypotf16_test.cpp.o
In file included from /usr/local/google/home/lntue/experiment/llvm-project/libc/test/src/math/exhaustive/hypotf16_test.cpp:11:
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/Hypot.h:210:18: warning: implicit conversion loses integer precision: 'int' to 'StorageType' (aka 'unsigned short') [-Wimplicit-int-conversion]
    r = (r << 1) + ((tail_bits & current_bit) ? 1 : 0);
      ~ ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/test/src/math/exhaustive/hypotf16_test.cpp:38:59: note: in instantiation of function template specialization '__llvm_libc_21_0_0_git::fputil::hypot<_Float16, 0>' requested here
        bool correct = TEST_FP_EQ(LIBC_NAMESPACE::fputil::hypot(x, y),
                                                          ^
In file included from /usr/local/google/home/lntue/experiment/llvm-project/libc/test/src/math/exhaustive/hypotf16_test.cpp:11:
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/Hypot.h:211:36: warning: implicit conversion loses integer precision: 'int' to 'StorageType' (aka 'unsigned short') [-Wimplicit-int-conversion]
    StorageType tmp = (y_new << 1) + current_bit; // 2*y_new(n - 1) + 2^(-n)
                ~~~   ~~~~~~~~~~~~~^~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/Hypot.h:33:15: warning: implicit conversion loses integer precision: 'int' to 'unsigned short' [-Wimplicit-int-conversion]
  return T(1) << shift_length;
  ~~~~~~ ~~~~~^~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/Hypot.h:158:29: note: in instantiation of function template specialization '__llvm_libc_21_0_0_git::fputil::internal::find_leading_one<unsigned short>' requested here
    leading_one = internal::find_leading_one(a_mant, y_mant_width);
                            ^
/usr/local/google/home/lntue/experiment/llvm-project/libc/test/src/math/exhaustive/hypotf16_test.cpp:38:59: note: in instantiation of function template specialization '__llvm_libc_21_0_0_git::fputil::hypot<_Float16, 0>' requested here
        bool correct = TEST_FP_EQ(LIBC_NAMESPACE::fputil::hypot(x, y),
```

https://github.com/llvm/llvm-project/pull/131991


More information about the libc-commits mailing list