Recent clang provides __bf16 on aarch64 but it is broken.
If built with -O0, the conversion is wrong:
$ printf '\x3F\x80' | od --end=big -An -tfB | tr -d ' '
1.875
If built with -O1 or higher, compilation fails:
fatal error: error in backend:
Cannot select: 0xb400007a58d29780: f32 = fp_extend 0xb40000...
0xb40000...: bf16,ch = CopyFromReg 0xb40000..., Register:bf16 %13
0xb40000...: bf16 = Register %13
In function: print_bfloat
The latter issue does not cause the existing configure test to fail
because the promotion is optimized out.
* configure.ac: Ensure 16 bit float promotion code does not get
optimized out, and produces an expected result.
# Test compiler support for half precision floating point types (for od)
AC_MSG_CHECKING([IEEE 16 bit floating point])
- AC_COMPILE_IFELSE(
+ AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
int
main (void)
{
- _Float16 hf;
+ volatile _Float16 hf = 1;
float f = hf; /* Ensure compiler can promote to float. */
+ return !(f == 1.0f);
}
]])
],[
fi
AC_MSG_CHECKING([Brain 16 bit floating point])
- AC_COMPILE_IFELSE(
+ AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
int
main (void)
{
- __bf16 hf;
+ volatile __bf16 hf = 1;
float f = hf; /* Ensure compiler can promote to float. */
+ return !(f == 1.0f);
}
]])
],[