[PATCH] Replace ABS macros with fabs
Szabolcs Nagy
szabolcs.nagy@arm.com
Fri May 15 08:35:00 GMT 2015
On 29/04/15 14:00, Wilco Dijkstra wrote:
>> Joseph Myers wrote:
>> On Mon, 27 Apr 2015, Wilco Dijkstra wrote:
>>
>>> GLIBC contains many uses of ABS macros which GCC is not able to optimize
>>> into fabs due to strict IEEE mode being used. On AArch64 GCC fails to
>>> use CSEL so several math functions contain many unnecessary and
>>> unpredictable branches. This patch removes the various ABS macros and
>>> replaces uses with fabs (or in one case abs) which is more efficient on
>>> all targets.
>>>
>>> OK for commit?
>>
>> OK given testing with math/ tests on x86_64 (I think the math/ tests
>> provide sufficient evidence that nothing was actually relying on the signs
>> of results of those macros for zero arguments where use of fabs changes
>> it; I've encountered various cases where including <math.h> in dbl-64
>> files nonobviously required such an include to be added to
>> sysdeps/x86_64/fpu/multiarch files as well because of some sort of include
>> ordering issue, so think an x86_64 build test is a good idea for any patch
>> like this that adds <math.h> includes to dbl-64 files).
>
> There was indeed an include ordering issue in sysdeps/x86_64/fpu/multiarch/e_log.c
> which included math_private.h before math.h, which is an easy fix.
>
fixed.
> Unfortunately it is not possible to build GLIBC unless you have the latest Linux
> kernel installed (there seem to be some odd dependencies on kernel headers and
> explicit kernel revision checks), so I can't build/test anything on x64 despite
> using latest GCC/binutils.
>
> So either someone else needs to give it a spin or I'll check in what I've got now.
>
did the tests: there are no ulp regressions on x86_64.
Wilco please commit it.
2015-05-15 Wilco Dijkstra <wdijkstr@arm.com>
* stdio-common/printf_fp.c (___printf_fp): Use abs.
* stdlib/gmp-impl.h (ABS): Remove define. (ABSIZ): Remove.
* sysdeps/ieee754/dbl-64/branred.c (__branred): Use fabs.
* sysdeps/ieee754/dbl-64/dla.h (EADD): Use fabs.
(ESUB): Use fabs. (ADD2): Use fabs. (SUB2): Use fabs.
(ADD2A): Use fabs. (SUB2A): Use fabs.
* sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_asin): Use fabs.
* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Use fabs.
* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Use fabs.
(log1): Use fabs. (my_log2): Use fabs.
* sysdeps/ieee754/dbl-64/e_remainder.c (__ieee754_remainder):
Use fabs.
* sysdeps/ieee754/dbl-64/mpa.h (ABS): Remove define.
* sysdeps/ieee754/dbl-64/mpatan.c (__mpatan): Use fabs.
* sysdeps/ieee754/dbl-64/mydefs.h (ABS): Remove define.
* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Use fabs.
(__cos): Use fabs. (slow): Use fabs. (slow2): Use fabs.
(sloww): Use fabs. (sloww1): Use fabs. (sloww2): Use fabs.
(bslow1): Use fabs. (bslow2): Use fabs. (cslow2): Use fabs.
(csloww): Use fabs. (csloww1): Use fabs. (csloww2): Use fabs.
* sysdeps/ieee754/dbl-64/sincos32.c (__mpranred): Use fabs.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fabs.diff
Type: text/x-patch
Size: 24934 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150515/3f5c988a/attachment.bin>
More information about the Libc-alpha
mailing list