This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 01/17] S390: Use load-fp-integer instruction for nearbyint functions.



On 04/11/2019 12:27, Stefan Liebler wrote:
> If compiled with z196 zarch support, the load-fp-integer instruction
> is used to implement nearbyint, nearbyintf, nearbyintl.
> Otherwise the common-code implementation is used.

> +
> +double
> +__nearbyint (double x)
> +{
> +  double y;
> +  /* The z196 zarch "load fp integer" (fidbra) instruction is rounding
> +     x to the nearest integer according to current rounding mode (M3-field: 0)
> +     where inexact exceptions are suppressed (M4-field: 4).  */
> +  __asm__ ("fidbra %0,0,%1,4" : "=f" (y) : "f" (x));
> +  return y;
> +}
> +libm_alias_double (__nearbyint, nearbyint)

At least with recent gcc __builtin_nearbyint generates the expected fidbra
instruction for -march=z196.  I wonder if we could start to simplify some
math symbols implementation where new architectures/extensions provide 
direct implementation by a direct mapping implemented by compiler builtins.

I would expect to:

  1. Move all sysdeps/ieee754/dbl-64/wordsize-64 to sysdeps/ieee754/dbl-64/
     since I hardly doubt these micro-optimizations really pay off with
     recent architectures and compiler version.

  2. Add internal macros __USE_<SYMBOL>_BUILTIN and use as:

     * sysdeps/ieee754/dbl-64/s_nearbyint.c
     
     [...]
     double
     __nearbyint (double x)
     {
     #if __USE_NEARBYINT_BUILTIN
       return __builtin_nearbyint (x);
     #else
       /* Use generic implementation.  */
     #endif
     }

  3. Define the __USE_<SYMBOL>_BUILTIN for each architecture.    

It would allow to simplify some architectures, aarch64 for instance.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]