This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 01/17] S390: Use load-fp-integer instruction for nearbyint functions.
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Mon, 2 Dec 2019 12:20:24 -0300
- Subject: Re: [PATCH 01/17] S390: Use load-fp-integer instruction for nearbyint functions.
- References: <1572881244-6781-1-git-send-email-stli@linux.ibm.com> <fc754475-f2cd-cb07-c527-1ccc567a4868@linaro.org> <146c3464-3a70-e2b9-e50f-46d2a27e056f@linux.ibm.com>
On 02/12/2019 11:56, Stefan Liebler wrote:
> On 11/4/19 7:22 PM, Adhemerval Zanella wrote:
>>
>>
>> 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.
>>
> This patch is superseded by the patch-series which is always using wordsize-64 version and allows to use the GCC builtins in common-code implementation:
> "[PATCH 00/13] Use GCC builtins for some math functions if desired."
> https://www.sourceware.org/ml/libc-alpha/2019-12/msg00029.html
>
> Bye,
> Stefan
>
Thanks, I will review these set.