foss-for-synopsys-dwc-arc-processors/glibc

Add extra check for availability of sqrt and fma instructions for ARC HS hw fpu variant

pavelvkozlov opened this issue · 1 comments

The compiler for ARC HS provides separate fpu options fpud_div, fpus_div, fpud_fma, fpus_fma and fpud_all to add use of FDDIV, FDSQRT, FSDIV, FSSQRT, FDMADD, FSMADD instructions.
So, it is possible to configure glibc with hw fpu support, but without support from the compiler side for such instructions. In this case __builtin_sqrt and __builtin_sqrtf provided by compiler can't be used inside the glibc code, as these builtins are used in implementations of sqrt() and sqrtf() functions but at the same time these builtins unfold to sqrt() and sqrtf() functions calls and bad code will be generated. Something like this:

0001c4b4 <__ieee754_sqrtf>:
   1c4b4:       0001 0000           b     0                     ;1c4b4 <__ieee754_sqrtf>

For additional details see also #484
The same is also true for __builtin_fma and __builtin_fmaf.

So, for general ARC variant in fpu sysdeps, extra check for compiler definitions __ARC_FPU_DP_DIV__, __ARC_FPU_SP_DIV__, __ARC_FPU_DP_FMA__, __ARC_FPU_SP_FMA__ should be added to the glibc code, before enable of use of sqrt and fma builtins.

Fixed by commit: d1b5f19