unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/28] powerpc floating-point optimization refactor
@ 2019-03-29 13:35 Adhemerval Zanella
  2019-03-29 13:35 ` [PATCH 01/28] powerpc: Use generic fabs{f} implementations Adhemerval Zanella
                   ` (27 more replies)
  0 siblings, 28 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This is a powerpc fpu refactor and simplification which consolidate
some assembly optimization in C implementation (which similar
performance result), remove some bloat optimizations which only
add code complexity, refactor IFUNC selection to disable unnecessary
selection on powercpc64le, and also optimize some symbols for
powerpc64le ISA 2.07+.

The idea is also to remove some build variation with different 
--with-cpu selection, more especially in implementation selection.
The powerpc sysdeps selection is currently quite convoluted and 
complex, with many variations due --with-cpu, and with the three
main ABIs sharing some rules. Worse, new chips/ISA only tend to 
make it worse and some chip-specific optimizations might not be
beneficial for a newer version.

My idea is to move powerpc64, or at least powerpc64le, more in
the direction of x86_64 and s390x are moving: a baseline build
without --with-cpu selection and IFUNC variation enable/disable
based on compiler flags (indicate through pre-processor defines).

This will simplify new chips addition (no more the need to add
multiple implies folders), build baseline will have fewer sysdeps
folder, and less possible variations that might be tested.

Although I focused on optimizing it for powerpc64le, both powerpc
and powerpc64 baselines builds results simplified code with
optimized results.  It also results in some binary size reduction
for libm:

$ size powerpc64-linux-gnu-master/math/libm.so
   text    data     bss     dec     hex filename
 803010   18044     576  821630   c897e powerpc64-linux-gnu-master/math/libm.so
$ size powerpc64-linux-gnu/math/libm.so
   text    data     bss     dec     hex filename
 796094   17284     504  813882   c6b3a powerpc64-linux-gnu/math/libm.so

$ size powerpc64le-linux-gnu-master/math/libm.so
   text    data     bss     dec     hex filename
1061284    2904     288 1064476  103e1c powerpc64le-linux-gnu-master/math/libm.so
$ size powerpc64le-linux-gnu/math/libm.so
   text    data     bss     dec     hex filename
1048772    2512     264 1051548  100b9c powerpc64le-linux-gnu/math/libm.so

For testing I tried to cover to different build option and optimization
which the code might result in different code generation:

  - powerpc-linux-gnu
  - powerpc-linux-gnu and --with-cpu=power4
  - powerpc-linux-gnu and --with-cpu=power5+
  - powerpc-linux-gnu and --with-cpu=power7
  - powerpc-linux-gnu and --with-cpu=power4 and --disable-arch
  - powerpc-linux-gnu and --with-cpu=power5+ and --disable-arch
  - powerpc-linux-gnu and --with-cpu=power7 and --disable-arch
  - powerpc64-linux-gnu
  - powerpc64le-linux-gnu
  - powerpc64le-linux-gnu and --disable-arch
  - powerpc64le-linux-gnu --with-cpu=power8

The compilers used are the one resulted from build-many-glibcs, which optimizes
for default minumum cpus.

Adhemerval Zanella (28):
  powerpc: Use generic fabs{f} implementations
  powerpc: fma using builtins
  powerpc: Remove power4 mpa optimization
  powerpc: ceil/ceilf refactor
  powerpc: floor/floorf refactor
  powerpc: round/roundf refactor
  powerpc: trunc/truncf refactor
  powerpc: generic nearbyint/nearbyintf
  powerpc: consolidate rint
  powerpc: copysign cleanup
  benchtests: Add isnan/isinf/isfinite benchmark
  math: Use wordsize-64 version for isnan
  powerpc: Remove optimized isnan
  math: Use wordsize-64 version for isinf
  powerpc: Remove optimized isinf
  math: Use wordsize-64 version for finite
  powerpc: Remove optimized finite
  powerpc: refactor powerpc64 lrint/lrintf/llrint/llrintf
  powerpc: Refactor powerpc32 lrint/lrintf/llrint/llrintf
  powerpc: Refactor powerpc64 lround/lroundf/llround/llroundf
  powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf
  powerpc: Use generic e_expf
  benchtests: hypot benchmark
  powerpc: hypot refactor and optimization
  powerpc: Refactor modf{f}
  benchtests: Add logb{f} benchmark
  math: Use wordsize-64 version for s_logb
  powerpc: refactor logb{f,l}

 benchtests/Makefile                           |   5 +-
 benchtests/hypot-inputs                       |  16 +
 benchtests/isfinite-inputs                    |  21 ++
 benchtests/isinf-inputs                       |  21 ++
 benchtests/isnan-inputs                       |  21 ++
 benchtests/logb-inputs                        |  11 +
 benchtests/logbf-inputs                       |  11 +
 sysdeps/ieee754/dbl-64/s_finite.c             |  22 +-
 sysdeps/ieee754/dbl-64/s_isinf.c              |  15 +-
 sysdeps/ieee754/dbl-64/s_isnan.c              |  17 +-
 sysdeps/ieee754/dbl-64/s_logb.c               |  61 ++--
 sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c |  43 ---
 sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c  |  34 --
 sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c  |  40 ---
 sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c   |  47 ---
 sysdeps/powerpc/fpu/e_hypot.c                 |  96 ++----
 sysdeps/powerpc/fpu/fenv_libc.h               |   8 +
 sysdeps/powerpc/fpu/round_to_integer.h        | 154 +++++++++
 sysdeps/powerpc/fpu/s_ceil.c                  |  35 ++
 sysdeps/powerpc/fpu/s_ceilf.c                 |  35 ++
 sysdeps/powerpc/fpu/s_copysign.c              |  32 ++
 sysdeps/powerpc/fpu/s_copysignf.c             |  28 ++
 sysdeps/powerpc/fpu/s_fabs.S                  |  33 --
 sysdeps/powerpc/fpu/s_fabsf.S                 |   1 -
 sysdeps/powerpc/fpu/s_floor.c                 |  35 ++
 sysdeps/powerpc/fpu/s_floorf.c                |  35 ++
 sysdeps/powerpc/fpu/{s_fma.S => s_fma.c}      |  12 +-
 sysdeps/powerpc/fpu/{s_fmaf.S => s_fmaf.c}    |  12 +-
 sysdeps/powerpc/fpu/s_isnan.c                 |  62 ----
 sysdeps/powerpc/fpu/s_isnanf.S                |   1 -
 sysdeps/powerpc/{power7 => }/fpu/s_logb.c     |  64 ++--
 sysdeps/powerpc/{power7 => }/fpu/s_logbf.c    |  44 ++-
 sysdeps/powerpc/{power7 => }/fpu/s_logbl.c    |  47 ++-
 sysdeps/powerpc/fpu/s_lrintf.S                |   1 -
 sysdeps/powerpc/fpu/s_lrintf.c                |   1 +
 sysdeps/powerpc/{power5+ => }/fpu/s_modf.c    |  17 +-
 sysdeps/powerpc/{power5+ => }/fpu/s_modff.c   |  13 +-
 sysdeps/powerpc/fpu/s_nearbyint.c             |  30 ++
 sysdeps/powerpc/fpu/s_nearbyintf.c            |  30 ++
 sysdeps/powerpc/fpu/s_rint.c                  |  19 +-
 sysdeps/powerpc/fpu/s_rintf.c                 |  19 +-
 sysdeps/powerpc/fpu/s_round.c                 |  35 ++
 sysdeps/powerpc/fpu/s_roundf.c                |  35 ++
 sysdeps/powerpc/fpu/s_trunc.c                 |  35 ++
 sysdeps/powerpc/fpu/s_truncf.c                |  35 ++
 sysdeps/powerpc/power4/fpu/Makefile           |   5 -
 sysdeps/powerpc/power4/fpu/mpa-arch.h         |  56 ----
 sysdeps/powerpc/power4/fpu/mpa.c              | 214 -------------
 sysdeps/powerpc/powerpc32/fpu/Makefile        |   7 +
 sysdeps/powerpc/powerpc32/fpu/s_ceil.S        |  76 -----
 sysdeps/powerpc/powerpc32/fpu/s_ceilf.S       |  76 -----
 sysdeps/powerpc/powerpc32/fpu/s_copysign.S    |  53 ---
 sysdeps/powerpc/powerpc32/fpu/s_copysignf.S   |   1 -
 sysdeps/powerpc/powerpc32/fpu/s_floor.S       |  76 -----
 sysdeps/powerpc/powerpc32/fpu/s_floorf.S      |  76 -----
 sysdeps/powerpc/powerpc32/fpu/s_isnan.S       |  57 ----
 sysdeps/powerpc/powerpc32/fpu/s_llrint.c      |   9 +
 sysdeps/powerpc/powerpc32/fpu/s_llrintf.c     |   7 +
 sysdeps/powerpc/powerpc32/fpu/s_llround.c     |  51 ++-
 sysdeps/powerpc/powerpc32/fpu/s_lrint.S       |  40 ---
 sysdeps/powerpc/powerpc32/fpu/s_lrint.c       |  40 +++
 sysdeps/powerpc/powerpc32/fpu/s_lround.S      | 123 -------
 sysdeps/powerpc/powerpc32/fpu/s_lround.c      |  77 +++++
 sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S   |  80 -----
 sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S  |  79 -----
 sysdeps/powerpc/powerpc32/fpu/s_rint.S        |  69 ----
 sysdeps/powerpc/powerpc32/fpu/s_rintf.S       |  66 ----
 sysdeps/powerpc/powerpc32/fpu/s_round.S       |  97 ------
 sysdeps/powerpc/powerpc32/fpu/s_roundf.S      |  96 ------
 sysdeps/powerpc/powerpc32/fpu/s_trunc.S       |  83 -----
 sysdeps/powerpc/powerpc32/fpu/s_truncf.S      |  83 -----
 .../powerpc32/power4/fpu/multiarch/Makefile   |  26 +-
 .../power4/fpu/multiarch/s_ceil-power5+.S     |  33 --
 .../power4/fpu/multiarch/s_ceil-power5+.c     |   3 +
 .../power4/fpu/multiarch/s_ceil-ppc32.S       |  31 --
 .../power4/fpu/multiarch/s_ceil-ppc32.c       |   3 +
 .../power4/fpu/multiarch/s_ceilf-power5+.S    |  26 --
 .../power4/fpu/multiarch/s_ceilf-power5+.c    |   3 +
 .../power4/fpu/multiarch/s_ceilf-ppc32.S      |  27 --
 .../power4/fpu/multiarch/s_ceilf-ppc32.c      |   3 +
 .../power4/fpu/multiarch/s_copysign-power6.S  |  33 --
 .../power4/fpu/multiarch/s_copysign-ppc32.S   |  34 --
 .../power4/fpu/multiarch/s_copysign.c         |  45 ---
 .../power4/fpu/multiarch/s_copysignf.c        |  34 --
 .../power4/fpu/multiarch/s_finite-power7.S    |  33 --
 .../power4/fpu/multiarch/s_finite-ppc32.c     |  33 --
 .../powerpc32/power4/fpu/multiarch/s_finite.c |  57 ----
 .../power4/fpu/multiarch/s_finitef-ppc32.c    |  31 --
 .../power4/fpu/multiarch/s_finitef.c          |  34 --
 .../power4/fpu/multiarch/s_floor-power5+.S    |  33 --
 .../power4/fpu/multiarch/s_floor-power5+.c    |   3 +
 .../power4/fpu/multiarch/s_floor-ppc32.S      |  31 --
 .../power4/fpu/multiarch/s_floor-ppc32.c      |   3 +
 .../power4/fpu/multiarch/s_floorf-power5+.S   |  26 --
 .../power4/fpu/multiarch/s_floorf-power5+.c   |   3 +
 .../power4/fpu/multiarch/s_floorf-ppc32.S     |  27 --
 .../power4/fpu/multiarch/s_floorf-ppc32.c     |   3 +
 .../power4/fpu/multiarch/s_isinf-power7.S     |  33 --
 .../power4/fpu/multiarch/s_isinf-ppc32.c      |  33 --
 .../powerpc32/power4/fpu/multiarch/s_isinf.c  |  50 ---
 .../power4/fpu/multiarch/s_isinff-ppc32.c     |  31 --
 .../powerpc32/power4/fpu/multiarch/s_isinff.c |  35 --
 .../power4/fpu/multiarch/s_isnan-power5.S     |  33 --
 .../power4/fpu/multiarch/s_isnan-power6.S     |  33 --
 .../power4/fpu/multiarch/s_isnan-power7.S     |  33 --
 .../power4/fpu/multiarch/s_isnan-ppc32.S      |  32 --
 .../powerpc32/power4/fpu/multiarch/s_isnan.c  |  56 ----
 .../power4/fpu/multiarch/s_isnanf-power5.S    |  28 --
 .../power4/fpu/multiarch/s_isnanf-power6.S    |  28 --
 .../powerpc32/power4/fpu/multiarch/s_isnanf.c |  39 ---
 .../power4/fpu/multiarch/s_llrint-power6.S    |  31 --
 .../power4/fpu/multiarch/s_llrint-power6.c    |   2 +
 .../power4/fpu/multiarch/s_llrint-ppc32.S     |  31 --
 .../power4/fpu/multiarch/s_llrint-ppc32.c     |   2 +
 .../power4/fpu/multiarch/s_llrintf-power6.S   |  26 --
 .../power4/fpu/multiarch/s_llrintf-power6.c   |   2 +
 .../power4/fpu/multiarch/s_llrintf-ppc32.S    |  26 --
 .../power4/fpu/multiarch/s_llrintf-ppc32.c    |   2 +
 .../power4/fpu/multiarch/s_llround-power5+.S  |  31 --
 .../power4/fpu/multiarch/s_llround-power5+.c  |   2 +
 .../power4/fpu/multiarch/s_llround-power6.S   |  31 --
 .../power4/fpu/multiarch/s_llround-power6.c   |   2 +
 .../power4/fpu/multiarch/s_llround-ppc32.S    |  31 --
 .../power4/fpu/multiarch/s_llround-ppc32.c    |   2 +
 .../power4/fpu/multiarch/s_logb-power7.c      |  13 +-
 .../power4/fpu/multiarch/s_logbf-power7.c     |   8 +-
 .../power4/fpu/multiarch/s_logbl-power7.c     |   3 +-
 .../power4/fpu/multiarch/s_lrint-ppc32.S      |  31 --
 .../power4/fpu/multiarch/s_lrint-ppc32.c      |   2 +
 .../power4/fpu/multiarch/s_lround-power5+.S   |  33 --
 .../power4/fpu/multiarch/s_lround-power5+.c   |   2 +
 .../power4/fpu/multiarch/s_lround-ppc32.S     |  31 --
 .../power4/fpu/multiarch/s_lround-ppc32.c     |   2 +
 .../power4/fpu/multiarch/s_modf-power5+.c     |  13 +-
 .../power4/fpu/multiarch/s_modff-power5+.c    |   9 +-
 .../power4/fpu/multiarch/s_round-power5+.S    |  33 --
 .../power4/fpu/multiarch/s_round-power5+.c    |   3 +
 .../power4/fpu/multiarch/s_round-ppc32.S      |  31 --
 .../power4/fpu/multiarch/s_round-ppc32.c      |   3 +
 .../power4/fpu/multiarch/s_roundf-power5+.S   |  26 --
 .../power4/fpu/multiarch/s_roundf-power5+.c   |   3 +
 .../power4/fpu/multiarch/s_roundf-ppc32.S     |  27 --
 .../power4/fpu/multiarch/s_roundf-ppc32.c     |   3 +
 .../power4/fpu/multiarch/s_trunc-power5+.S    |  33 --
 .../power4/fpu/multiarch/s_trunc-power5+.c    |   3 +
 .../power4/fpu/multiarch/s_trunc-ppc32.S      |  31 --
 .../power4/fpu/multiarch/s_trunc-ppc32.c      |   3 +
 .../power4/fpu/multiarch/s_truncf-power5+.S   |  26 --
 .../power4/fpu/multiarch/s_truncf-power5+.c   |   3 +
 .../power4/fpu/multiarch/s_truncf-ppc32.S     |  27 --
 .../power4/fpu/multiarch/s_truncf-ppc32.c     |   3 +
 .../powerpc/powerpc32/power4/fpu/s_llrint.S   |  39 ---
 .../powerpc/powerpc32/power4/fpu/s_llrintf.S  |  39 ---
 .../powerpc/powerpc32/power4/fpu/s_llround.S  | 105 ------
 .../powerpc/powerpc32/power4/fpu/s_llroundf.S |   1 -
 .../powerpc/powerpc32/power5+/fpu/s_ceil.S    |  29 --
 .../powerpc/powerpc32/power5+/fpu/s_ceilf.S   |  30 --
 .../powerpc/powerpc32/power5+/fpu/s_floor.S   |  29 --
 .../powerpc/powerpc32/power5+/fpu/s_floorf.S  |  30 --
 .../powerpc/powerpc32/power5+/fpu/s_llround.S |  53 ---
 .../powerpc32/power5+/fpu/s_llroundf.S        |   1 -
 .../powerpc/powerpc32/power5+/fpu/s_lround.S  |  51 ---
 .../powerpc/powerpc32/power5+/fpu/s_round.S   |  29 --
 .../powerpc/powerpc32/power5+/fpu/s_roundf.S  |  30 --
 .../powerpc/powerpc32/power5+/fpu/s_trunc.S   |  29 --
 .../powerpc/powerpc32/power5+/fpu/s_truncf.S  |  30 --
 .../powerpc/powerpc32/power5/fpu/s_isnan.S    |  61 ----
 .../powerpc/powerpc32/power5/fpu/s_isnanf.S   |  45 ---
 .../powerpc/powerpc32/power6/fpu/s_copysign.S |  49 ---
 .../powerpc32/power6/fpu/s_copysignf.S        |   1 -
 .../powerpc/powerpc32/power6/fpu/s_isnan.S    |  61 ----
 .../powerpc/powerpc32/power6/fpu/s_isnanf.S   |  44 ---
 .../powerpc/powerpc32/power6/fpu/s_llrint.S   |  39 ---
 .../powerpc/powerpc32/power6/fpu/s_llrintf.S  |  39 ---
 .../powerpc/powerpc32/power6/fpu/s_llround.S  |  53 ---
 .../powerpc/powerpc32/power6/fpu/s_llroundf.S |   1 -
 .../powerpc/powerpc32/power7/fpu/s_finite.S   |  93 ------
 .../powerpc/powerpc32/power7/fpu/s_finitef.S  |   1 -
 .../powerpc/powerpc32/power7/fpu/s_isinf.S    |  85 -----
 .../powerpc/powerpc32/power7/fpu/s_isinff.S   |   1 -
 .../powerpc/powerpc32/power7/fpu/s_isnan.S    |  90 ------
 .../powerpc/powerpc32/power7/fpu/s_isnanf.S   |   1 -
 .../powerpc64/be/fpu/multiarch/Makefile       |  65 ++++
 .../be/fpu/multiarch/s_ceil-power5+.c         |   3 +
 .../powerpc64/be/fpu/multiarch/s_ceil-ppc64.c |   3 +
 .../powerpc64/{ => be}/fpu/multiarch/s_ceil.c |   4 +-
 .../be/fpu/multiarch/s_ceilf-power5+.c        |   3 +
 .../be/fpu/multiarch/s_ceilf-ppc64.c          |   3 +
 .../{ => be}/fpu/multiarch/s_ceilf.c          |   4 +-
 .../be/fpu/multiarch/s_floor-power5+.c        |   3 +
 .../be/fpu/multiarch/s_floor-ppc64.c          |   3 +
 .../{ => be}/fpu/multiarch/s_floor.c          |   0
 .../be/fpu/multiarch/s_floorf-power5+.c       |   3 +
 .../be/fpu/multiarch/s_floorf-ppc64.c         |   3 +
 .../{ => be}/fpu/multiarch/s_floorf.c         |   0
 .../be/fpu/multiarch/s_llrint-power6x.c       |   2 +
 .../be/fpu/multiarch/s_llrint-power8.c        |   2 +
 .../be/fpu/multiarch/s_llrint-ppc64.c         |   2 +
 .../{ => be}/fpu/multiarch/s_llrint.c         |   0
 .../{ => be}/fpu/multiarch/s_llrintf.c        |   0
 .../be/fpu/multiarch/s_llround-power5+.c      |   2 +
 .../be/fpu/multiarch/s_llround-power6x.c      |   2 +
 .../be/fpu/multiarch/s_llround-power8.c       |   2 +
 .../be/fpu/multiarch/s_llround-ppc64.c        |   2 +
 .../{ => be}/fpu/multiarch/s_llround.c        |   0
 .../be/fpu/multiarch/s_llroundf-ppc64.c       |   2 +
 .../{ => be}/fpu/multiarch/s_llroundf.c       |   0
 .../{ => be}/fpu/multiarch/s_logb-power7.c    |   3 +-
 .../{ => be}/fpu/multiarch/s_logb-ppc64.c     |   0
 .../powerpc64/{ => be}/fpu/multiarch/s_logb.c |   0
 .../{ => be}/fpu/multiarch/s_logbf-power7.c   |   3 +-
 .../{ => be}/fpu/multiarch/s_logbf-ppc64.c    |   0
 .../{ => be}/fpu/multiarch/s_logbf.c          |   0
 .../{ => be}/fpu/multiarch/s_logbl-power7.c   |   3 +-
 .../{ => be}/fpu/multiarch/s_logbl-ppc64.c    |   0
 .../{ => be}/fpu/multiarch/s_logbl.c          |   0
 .../{ => be}/fpu/multiarch/s_lrint.c          |   0
 .../{ => be}/fpu/multiarch/s_lround.c         |   0
 .../{ => be}/fpu/multiarch/s_modf-power5+.c   |   3 +-
 .../{ => be}/fpu/multiarch/s_modf-ppc64.c     |   0
 .../powerpc64/{ => be}/fpu/multiarch/s_modf.c |   0
 .../{ => be}/fpu/multiarch/s_modff-power5+.c  |   3 +-
 .../{ => be}/fpu/multiarch/s_modff-ppc64.c    |   0
 .../{ => be}/fpu/multiarch/s_modff.c          |   0
 .../be/fpu/multiarch/s_round-power5+.c        |   3 +
 .../be/fpu/multiarch/s_round-ppc64.c          |   3 +
 .../{ => be}/fpu/multiarch/s_round.c          |   0
 .../be/fpu/multiarch/s_roundf-power5+.c       |   3 +
 .../be/fpu/multiarch/s_roundf-ppc64.c         |   3 +
 .../{ => be}/fpu/multiarch/s_roundf.c         |   2 -
 .../be/fpu/multiarch/s_trunc-power5+.c        |   3 +
 .../be/fpu/multiarch/s_trunc-ppc64.c          |   3 +
 .../{ => be}/fpu/multiarch/s_trunc.c          |   0
 .../be/fpu/multiarch/s_truncf-power5+.c       |   3 +
 .../be/fpu/multiarch/s_truncf-ppc64.c         |   3 +
 .../{ => be}/fpu/multiarch/s_truncf.c         |   2 -
 sysdeps/powerpc/powerpc64/fpu/Makefile        |   7 +
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  44 ---
 .../powerpc64/fpu/multiarch/e_expf-power8.S   |  24 --
 .../powerpc64/fpu/multiarch/e_expf-ppc64.c    |  21 --
 .../powerpc/powerpc64/fpu/multiarch/e_expf.c  |  32 --
 .../powerpc64/fpu/multiarch/e_hypot-power7.c  |  19 --
 .../powerpc64/fpu/multiarch/e_hypot-ppc64.c   |  26 --
 .../powerpc/powerpc64/fpu/multiarch/e_hypot.c |  33 --
 .../powerpc64/fpu/multiarch/e_hypotf-power7.c |  19 --
 .../powerpc64/fpu/multiarch/e_hypotf-ppc64.c  |  26 --
 .../powerpc64/fpu/multiarch/e_hypotf.c        |  33 --
 .../powerpc64/fpu/multiarch/s_ceil-power5+.S  |  30 --
 .../powerpc64/fpu/multiarch/s_ceil-ppc64.S    |  30 --
 .../powerpc64/fpu/multiarch/s_ceilf-power5+.S |  24 --
 .../powerpc64/fpu/multiarch/s_ceilf-ppc64.S   |  24 --
 .../fpu/multiarch/s_copysign-power6.S         |  32 --
 .../fpu/multiarch/s_copysign-ppc64.S          |  34 --
 .../powerpc64/fpu/multiarch/s_copysign.c      |  45 ---
 .../powerpc64/fpu/multiarch/s_copysignf.c     |  34 --
 .../powerpc64/fpu/multiarch/s_finite-power7.S |  32 --
 .../powerpc64/fpu/multiarch/s_finite-power8.S |  32 --
 .../powerpc64/fpu/multiarch/s_finite-ppc64.c  |  34 --
 .../powerpc64/fpu/multiarch/s_finite.c        |  69 ----
 .../powerpc64/fpu/multiarch/s_finitef-ppc64.c |  32 --
 .../powerpc64/fpu/multiarch/s_finitef.c       |  37 ---
 .../powerpc64/fpu/multiarch/s_floor-power5+.S |  30 --
 .../powerpc64/fpu/multiarch/s_floor-ppc64.S   |  30 --
 .../fpu/multiarch/s_floorf-power5+.S          |  24 --
 .../powerpc64/fpu/multiarch/s_floorf-ppc64.S  |  24 --
 .../powerpc64/fpu/multiarch/s_isinf-power7.S  |  32 --
 .../powerpc64/fpu/multiarch/s_isinf-power8.S  |  32 --
 .../powerpc64/fpu/multiarch/s_isinf-ppc64.c   |  33 --
 .../powerpc/powerpc64/fpu/multiarch/s_isinf.c |  62 ----
 .../powerpc64/fpu/multiarch/s_isinff-ppc64.c  |  31 --
 .../powerpc64/fpu/multiarch/s_isinff.c        |  38 ---
 .../powerpc64/fpu/multiarch/s_isnan-power5.S  |  32 --
 .../powerpc64/fpu/multiarch/s_isnan-power6.S  |  32 --
 .../powerpc64/fpu/multiarch/s_isnan-power6x.S |  32 --
 .../powerpc64/fpu/multiarch/s_isnan-power7.S  |  32 --
 .../powerpc64/fpu/multiarch/s_isnan-power8.S  |  32 --
 .../powerpc64/fpu/multiarch/s_isnan-ppc64.S   |  36 ---
 .../powerpc/powerpc64/fpu/multiarch/s_isnan.c |  71 ----
 .../powerpc64/fpu/multiarch/s_isnanf.c        |  44 ---
 .../fpu/multiarch/s_llrint-power6x.S          |  30 --
 .../powerpc64/fpu/multiarch/s_llrint-power8.S |  30 --
 .../powerpc64/fpu/multiarch/s_llrint-ppc64.S  |  30 --
 .../fpu/multiarch/s_llround-power5+.S         |  31 --
 .../fpu/multiarch/s_llround-power6x.S         |  31 --
 .../fpu/multiarch/s_llround-power8.S          |  30 --
 .../powerpc64/fpu/multiarch/s_llround-ppc64.S |  27 --
 .../fpu/multiarch/s_llroundf-ppc64.S          |  31 --
 .../powerpc64/fpu/multiarch/s_round-power5+.S |  30 --
 .../powerpc64/fpu/multiarch/s_round-ppc64.S   |  30 --
 .../fpu/multiarch/s_roundf-power5+.S          |  24 --
 .../powerpc64/fpu/multiarch/s_roundf-ppc64.S  |  24 --
 .../powerpc64/fpu/multiarch/s_trunc-power5+.S |  30 --
 .../powerpc64/fpu/multiarch/s_trunc-ppc64.S   |  30 --
 .../fpu/multiarch/s_truncf-power5+.S          |  24 --
 .../powerpc64/fpu/multiarch/s_truncf-ppc64.S  |  24 --
 .../powerpc/powerpc64/fpu/multiarch/w_expf.c  |   1 -
 sysdeps/powerpc/powerpc64/fpu/s_ceil.S        |  65 ----
 sysdeps/powerpc/powerpc64/fpu/s_ceilf.S       |  67 ----
 sysdeps/powerpc/powerpc64/fpu/s_copysign.S    |  53 ---
 sysdeps/powerpc/powerpc64/fpu/s_copysignf.S   |   1 -
 sysdeps/powerpc/powerpc64/fpu/s_floor.S       |  65 ----
 sysdeps/powerpc/powerpc64/fpu/s_floorf.S      |  67 ----
 sysdeps/powerpc/powerpc64/fpu/s_isnan.S       |  56 ----
 sysdeps/powerpc/powerpc64/fpu/s_llrint.S      |  45 ---
 sysdeps/powerpc/powerpc64/fpu/s_llrint.c      |  55 ++++
 sysdeps/powerpc/powerpc64/fpu/s_llrintf.S     |   1 -
 sysdeps/powerpc/powerpc64/fpu/s_llrintf.c     |   1 +
 sysdeps/powerpc/powerpc64/fpu/s_llround.S     |  86 -----
 sysdeps/powerpc/powerpc64/fpu/s_llround.c     |  83 +++++
 sysdeps/powerpc/powerpc64/fpu/s_llroundf.S    |  89 -----
 sysdeps/powerpc/powerpc64/fpu/s_llroundf.c    |  83 +++++
 sysdeps/powerpc/powerpc64/fpu/s_lrint.S       |   1 -
 sysdeps/powerpc/powerpc64/fpu/s_lrint.c       |   1 +
 sysdeps/powerpc/powerpc64/fpu/s_lround.S      |   1 -
 sysdeps/powerpc/powerpc64/fpu/s_lround.c      |   1 +
 sysdeps/powerpc/powerpc64/fpu/s_lroundf.S     |   1 -
 sysdeps/powerpc/powerpc64/fpu/s_lroundf.c     |   1 +
 sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S   |  68 ----
 sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S  |  69 ----
 sysdeps/powerpc/powerpc64/fpu/s_rint.S        |  58 ----
 sysdeps/powerpc/powerpc64/fpu/s_rintf.S       |  57 ----
 sysdeps/powerpc/powerpc64/fpu/s_round.S       |  80 -----
 sysdeps/powerpc/powerpc64/fpu/s_roundf.S      |  82 -----
 sysdeps/powerpc/powerpc64/fpu/s_trunc.S       |  72 -----
 sysdeps/powerpc/powerpc64/fpu/s_truncf.S      |  74 -----
 .../powerpc/powerpc64/power5+/fpu/s_ceil.S    |  30 --
 .../powerpc/powerpc64/power5+/fpu/s_ceilf.S   |  31 --
 .../powerpc/powerpc64/power5+/fpu/s_floor.S   |  30 --
 .../powerpc/powerpc64/power5+/fpu/s_floorf.S  |  31 --
 .../powerpc/powerpc64/power5+/fpu/s_llround.S |  56 ----
 .../powerpc64/power5+/fpu/s_llroundf.S        |   1 -
 .../powerpc/powerpc64/power5+/fpu/s_round.S   |  30 --
 .../powerpc/powerpc64/power5+/fpu/s_roundf.S  |  31 --
 .../powerpc/powerpc64/power5+/fpu/s_trunc.S   |  30 --
 .../powerpc/powerpc64/power5+/fpu/s_truncf.S  |  31 --
 .../powerpc/powerpc64/power5/fpu/s_isnan.S    |  60 ----
 .../powerpc/powerpc64/power6/fpu/s_copysign.S |  49 ---
 .../powerpc64/power6/fpu/s_copysignf.S        |   1 -
 .../powerpc/powerpc64/power6/fpu/s_isnan.S    |  59 ----
 .../powerpc/powerpc64/power6x/fpu/s_isnan.S   |  58 ----
 .../powerpc/powerpc64/power6x/fpu/s_llrint.S  |  42 ---
 .../powerpc/powerpc64/power6x/fpu/s_llround.S |  52 ---
 .../powerpc64/power6x/fpu/s_llroundf.S        |   1 -
 .../powerpc/powerpc64/power7/fpu/s_finite.S   |  70 ----
 .../powerpc/powerpc64/power7/fpu/s_finitef.S  |   1 -
 .../powerpc/powerpc64/power7/fpu/s_isinf.S    |  69 ----
 .../powerpc/powerpc64/power7/fpu/s_isinff.S   |   1 -
 .../powerpc/powerpc64/power7/fpu/s_isnan.S    |  68 ----
 .../powerpc/powerpc64/power7/fpu/s_isnanf.S   |   1 -
 sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c |   1 -
 .../powerpc/powerpc64/power7/fpu/s_logbf.c    |   1 -
 .../powerpc/powerpc64/power7/fpu/s_logbl.c    |   1 -
 sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S | 303 ------------------
 .../powerpc/powerpc64/power8/fpu/s_finite.S   |  56 ----
 .../powerpc/powerpc64/power8/fpu/s_finitef.S  |   1 -
 .../powerpc/powerpc64/power8/fpu/s_isinf.S    |  61 ----
 .../powerpc/powerpc64/power8/fpu/s_isinff.S   |   1 -
 .../powerpc/powerpc64/power8/fpu/s_isnan.S    |  56 ----
 .../powerpc/powerpc64/power8/fpu/s_isnanf.S   |   1 -
 .../powerpc/powerpc64/power8/fpu/s_llrint.S   |  43 ---
 .../powerpc/powerpc64/power8/fpu/s_llround.S  |  46 ---
 .../powerpc/powerpc64/power8/fpu/s_llroundf.S |   1 -
 sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c |   1 -
 363 files changed, 1494 insertions(+), 9311 deletions(-)
 create mode 100644 benchtests/hypot-inputs
 create mode 100644 benchtests/isfinite-inputs
 create mode 100644 benchtests/isinf-inputs
 create mode 100644 benchtests/isnan-inputs
 create mode 100644 benchtests/logb-inputs
 create mode 100644 benchtests/logbf-inputs
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
 create mode 100644 sysdeps/powerpc/fpu/round_to_integer.h
 create mode 100644 sysdeps/powerpc/fpu/s_ceil.c
 create mode 100644 sysdeps/powerpc/fpu/s_ceilf.c
 create mode 100644 sysdeps/powerpc/fpu/s_copysign.c
 create mode 100644 sysdeps/powerpc/fpu/s_copysignf.c
 delete mode 100644 sysdeps/powerpc/fpu/s_fabs.S
 delete mode 100644 sysdeps/powerpc/fpu/s_fabsf.S
 create mode 100644 sysdeps/powerpc/fpu/s_floor.c
 create mode 100644 sysdeps/powerpc/fpu/s_floorf.c
 rename sysdeps/powerpc/fpu/{s_fma.S => s_fma.c} (82%)
 rename sysdeps/powerpc/fpu/{s_fmaf.S => s_fmaf.c} (82%)
 delete mode 100644 sysdeps/powerpc/fpu/s_isnan.c
 delete mode 100644 sysdeps/powerpc/fpu/s_isnanf.S
 rename sysdeps/powerpc/{power7 => }/fpu/s_logb.c (56%)
 rename sysdeps/powerpc/{power7 => }/fpu/s_logbf.c (67%)
 rename sysdeps/powerpc/{power7 => }/fpu/s_logbl.c (72%)
 delete mode 100644 sysdeps/powerpc/fpu/s_lrintf.S
 create mode 100644 sysdeps/powerpc/fpu/s_lrintf.c
 rename sysdeps/powerpc/{power5+ => }/fpu/s_modf.c (74%)
 rename sysdeps/powerpc/{power5+ => }/fpu/s_modff.c (77%)
 create mode 100644 sysdeps/powerpc/fpu/s_nearbyint.c
 create mode 100644 sysdeps/powerpc/fpu/s_nearbyintf.c
 create mode 100644 sysdeps/powerpc/fpu/s_round.c
 create mode 100644 sysdeps/powerpc/fpu/s_roundf.c
 create mode 100644 sysdeps/powerpc/fpu/s_trunc.c
 create mode 100644 sysdeps/powerpc/fpu/s_truncf.c
 delete mode 100644 sysdeps/powerpc/power4/fpu/Makefile
 delete mode 100644 sysdeps/powerpc/power4/fpu/mpa-arch.h
 delete mode 100644 sysdeps/powerpc/power4/fpu/mpa.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_ceilf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_copysignf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_floorf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lrint.S
 create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lrint.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lround.S
 create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lround.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_rint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_rintf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_roundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_truncf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power5.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-ppc32.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power5.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isinff.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isnanf.S
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_ceil.c (95%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_ceilf.c (95%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_floor.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_floorf.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power6x.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power8.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llrint.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llrintf.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power6x.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power8.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llround.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llroundf.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logb-power7.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logb-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logb.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbf-power7.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbf-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbf.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbl-power7.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbl-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbl.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_lrint.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_lround.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modf-power5+.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modf-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modf.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modff-power5+.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modff-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modff.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_round.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_roundf.c (95%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_trunc.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_truncf.c (95%)
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/Makefile
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power5.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6x.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power6x.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power6x.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_ceilf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_copysignf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_floorf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrint.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrint.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintf.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llround.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llround.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llroundf.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llroundf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lrint.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lrint.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lround.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lround.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lroundf.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lroundf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_rint.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_rintf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_roundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_truncf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/fpu/s_copysignf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_finitef.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isinff.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_logbf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_logbl.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_finitef.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isinff.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH 01/28] powerpc: Use generic fabs{f} implementations
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-04-01 20:04   ` Joseph Myers
  2019-03-29 13:35 ` [PATCH 02/28] powerpc: fma using builtins Adhemerval Zanella
                   ` (26 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

Since be2e25bbd78f9fdf the generic ieee754 implementation uses
compiler builtin which generates fabs{f} for all supported targets.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/s_fabs.S: Remove file.
	* sysdeps/powerpc/fpu/s_fabsf.S: Likewise.
---
 sysdeps/powerpc/fpu/s_fabs.S  | 33 ---------------------------------
 sysdeps/powerpc/fpu/s_fabsf.S |  1 -
 2 files changed, 34 deletions(-)
 delete mode 100644 sysdeps/powerpc/fpu/s_fabs.S
 delete mode 100644 sysdeps/powerpc/fpu/s_fabsf.S

diff --git a/sysdeps/powerpc/fpu/s_fabs.S b/sysdeps/powerpc/fpu/s_fabs.S
deleted file mode 100644
index 7147f6b4a2..0000000000
--- a/sysdeps/powerpc/fpu/s_fabs.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Floating-point absolute value.  PowerPC version.
-   Copyright (C) 1997-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-ENTRY(__fabs)
-/* double [f1] fabs (double [f1] x); */
-	fabs fp1,fp1
-	blr
-END(__fabs)
-
-libm_alias_double (__fabs, fabs)
-
-/* It turns out that it's safe to use this code even for single-precision.  */
-strong_alias(__fabs,__fabsf)
-libm_alias_float (__fabs, fabs)
diff --git a/sysdeps/powerpc/fpu/s_fabsf.S b/sysdeps/powerpc/fpu/s_fabsf.S
deleted file mode 100644
index 877c710ce8..0000000000
--- a/sysdeps/powerpc/fpu/s_fabsf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __fabsf is in s_fabs.S  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 02/28] powerpc: fma using builtins
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
  2019-03-29 13:35 ` [PATCH 01/28] powerpc: Use generic fabs{f} implementations Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-04-01 20:05   ` Joseph Myers
  2019-03-29 13:35 ` [PATCH 03/28] powerpc: Remove power4 mpa optimization Adhemerval Zanella
                   ` (25 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patch just refactor the assembly implementation to use compiler
builtins instead.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/s_fma.S: Remove file.
	* sysdeps/powerpc/fpu/s_fmaf.S: Likewise.
	* sysdeps/powerpc/fpu/s_fma.c: New file.
	* sysdeps/powerpc/fpu/s_fmaf.c: Likewise.
---
 sysdeps/powerpc/fpu/{s_fma.S => s_fma.c}   | 12 +++++-------
 sysdeps/powerpc/fpu/{s_fmaf.S => s_fmaf.c} | 12 +++++-------
 2 files changed, 10 insertions(+), 14 deletions(-)
 rename sysdeps/powerpc/fpu/{s_fma.S => s_fma.c} (82%)
 rename sysdeps/powerpc/fpu/{s_fmaf.S => s_fmaf.c} (82%)

diff --git a/sysdeps/powerpc/fpu/s_fma.S b/sysdeps/powerpc/fpu/s_fma.c
similarity index 82%
rename from sysdeps/powerpc/fpu/s_fma.S
rename to sysdeps/powerpc/fpu/s_fma.c
index 92e08eb583..688f9badf5 100644
--- a/sysdeps/powerpc/fpu/s_fma.S
+++ b/sysdeps/powerpc/fpu/s_fma.c
@@ -1,5 +1,5 @@
 /* Compute x * y + z as ternary operation.  PowerPC version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,10 +19,8 @@
 #include <sysdep.h>
 #include <libm-alias-double.h>
 
-ENTRY_TOCLESS(__fma)
-/* double [f1] fma (double [f1] x, double [f2] y, double [f3] z); */
-	fmadd	fp1,fp1,fp2,fp3
-	blr
-END(__fma)
-
+double __fma (double x, double y, double z)
+{
+  return __builtin_fma (x, y, z);
+}
 libm_alias_double (__fma, fma)
diff --git a/sysdeps/powerpc/fpu/s_fmaf.S b/sysdeps/powerpc/fpu/s_fmaf.c
similarity index 82%
rename from sysdeps/powerpc/fpu/s_fmaf.S
rename to sysdeps/powerpc/fpu/s_fmaf.c
index 9579e9492e..38b59e1f2f 100644
--- a/sysdeps/powerpc/fpu/s_fmaf.S
+++ b/sysdeps/powerpc/fpu/s_fmaf.c
@@ -1,5 +1,5 @@
 /* Compute x * y + z as ternary operation.  PowerPC version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,10 +19,8 @@
 #include <sysdep.h>
 #include <libm-alias-float.h>
 
-ENTRY_TOCLESS(__fmaf)
-/* float [f1] fmaf (float [f1] x, float [f2] y, float [f3] z); */
-	fmadds	fp1,fp1,fp2,fp3
-	blr
-END(__fmaf)
-
+float __fmaf (float x, float y, float z)
+{
+  return __builtin_fmaf (x, y, z);
+}
 libm_alias_float (__fma, fma)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 03/28] powerpc: Remove power4 mpa optimization
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
  2019-03-29 13:35 ` [PATCH 01/28] powerpc: Use generic fabs{f} implementations Adhemerval Zanella
  2019-03-29 13:35 ` [PATCH 02/28] powerpc: fma using builtins Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-04-24 21:51   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 04/28] powerpc: ceil/ceilf refactor Adhemerval Zanella
                   ` (24 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patch removes the POWER4 optimized mpa optimization used for power4+
build.  For newer chips, GCC generates *worse* code than generic
implementation as benchmaks result below.  One possibilty would to add
IFUNC variants for the mpa routines (as x86_64), but it will add complexity
only for older chips (and one would need to check if power5, power5+, and
power6 do benefict from this optimization), and only for specific
implementation (since most used ones such as sin, cos, exp, pow already
avoid calling the slow multiprecision path).

  * POWER9 patched
    "atan": {
     "": {
      "duration": 5.12565e+09,
      "iterations": 1.552e+08,
      "max": 100.552,
      "min": 7.799,
      "mean": 33.0261
     },
     "144bits": {
      "duration": 5.12745e+09,
      "iterations": 825000,
      "max": 7517.17,
      "min": 6186.3,
      "mean": 6215.09
     }
    }
    "acos": {
     "": {
      "duration": 5.21741e+09,
      "iterations": 1.269e+08,
      "max": 191.738,
      "min": 7.931,
      "mean": 41.1144
     },
     "slow": {
      "duration": 5.25999e+09,
      "iterations": 198000,
      "max": 26681.7,
      "min": 26463.6,
      "mean": 26565.6
     }
    }

  * POWER9 master
    "atan": {
     "": {
      "duration": 5.12815e+09,
      "iterations": 1.552e+08,
      "max": 134.788,
      "min": 7.803,
      "mean": 33.0422
     },
     "144bits": {
      "duration": 5.1209e+09,
      "iterations": 447000,
      "max": 11615.8,
      "min": 11301.8,
      "mean": 11456.2
     }
    }
    "acos": {
     "": {
      "duration": 5.22272e+09,
      "iterations": 1.269e+08,
      "max": 115.981,
      "min": 7.931,
      "mean": 41.1562
     },
     "slow": {
      "duration": 5.28723e+09,
      "iterations": 96000,
      "max": 55434.1,
      "min": 54820.6,
      "mean": 55075.3
     }
    }

  * POWER8 patched
    "acos": {
     "": {
      "duration": 5.16398e+09,
      "iterations": 9.99e+07,
      "max": 174.408,
      "min": 8.645,
      "mean": 51.6915
     },
     "slow": {
      "duration": 5.16982e+09,
      "iterations": 96000,
      "max": 54830.5,
      "min": 53703.8,
      "mean": 53852.3
     }
    }
  * POWER8 master
    "acos": {
     "": {
      "duration": 5.17019e+09,
      "iterations": 9.99e+07,
      "max": 186.127,
      "min": 8.633,
      "mean": 51.7537
     },
     "slow": {
      "duration": 5.34225e+09,
      "iterations": 90000,
      "max": 60353.2,
      "min": 59155.3,
      "mean": 59358.4
     }
    }

  * POWER7 patched
    "asin": {
     "": {
      "duration": 5.15559e+09,
      "iterations": 6.5e+07,
      "max": 193.335,
      "min": 12.227,
      "mean": 79.3168
     },
     "slow": {
      "duration": 5.20538e+09,
      "iterations": 80000,
      "max": 65705.2,
      "min": 64299.4,
      "mean": 65067.3
     }
    }
  * POWER7 master
    "asin": {
     "": {
      "duration": 5.15446e+09,
      "iterations": 6.5e+07,
      "max": 184.575,
      "min": 12.226,
      "mean": 79.2994
     },
     "slow": {
      "duration": 5.20616e+09,
      "iterations": 80000,
      "max": 65705.1,
      "min": 64336.6,
      "mean": 65076.9
     }
    }

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/power4/fpu/Makefile: Remove file.
	* sysdeps/powerpc/power4/fpu/mpa-arch.h: Likewise.
	* sysdeps/powerpc/power4/fpu/mpa.c: Likewise.
---
 sysdeps/powerpc/power4/fpu/Makefile   |   5 -
 sysdeps/powerpc/power4/fpu/mpa-arch.h |  56 -------
 sysdeps/powerpc/power4/fpu/mpa.c      | 214 --------------------------
 3 files changed, 275 deletions(-)
 delete mode 100644 sysdeps/powerpc/power4/fpu/Makefile
 delete mode 100644 sysdeps/powerpc/power4/fpu/mpa-arch.h
 delete mode 100644 sysdeps/powerpc/power4/fpu/mpa.c

diff --git a/sysdeps/powerpc/power4/fpu/Makefile b/sysdeps/powerpc/power4/fpu/Makefile
deleted file mode 100644
index f487ed6014..0000000000
--- a/sysdeps/powerpc/power4/fpu/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# Makefile fragment for POWER4/5/5+ with FPU.
-
-ifeq ($(subdir),math)
-CFLAGS-mpa.c += --param max-unroll-times=4 -funroll-loops -fpeel-loops
-endif
diff --git a/sysdeps/powerpc/power4/fpu/mpa-arch.h b/sysdeps/powerpc/power4/fpu/mpa-arch.h
deleted file mode 100644
index 929c60b314..0000000000
--- a/sysdeps/powerpc/power4/fpu/mpa-arch.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Overridable constants and operations.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2.1 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
-
-typedef double mantissa_t;
-typedef double mantissa_store_t;
-
-#define TWOPOW(i) (0x1.0p##i)
-
-#define RADIX TWOPOW (24)		/* 2^24    */
-#define CUTTER TWOPOW (76)		/* 2^76    */
-#define RADIXI 0x1.0p-24		/* 2^-24 */
-#define TWO52 TWOPOW (52)		/* 2^52 */
-
-/* Divide D by RADIX and put the remainder in R.  */
-#define DIV_RADIX(d,r) \
-  ({									      \
-    double u = ((d) + CUTTER) - CUTTER;					      \
-    if (u > (d))							      \
-      u -= RADIX;							      \
-    r = (d) - u;							      \
-    (d) = u * RADIXI;							      \
-  })
-
-/* Put the integer component of a double X in R and retain the fraction in
-   X.  */
-#define INTEGER_OF(x, r) \
-  ({									      \
-    double u = ((x) + TWO52) - TWO52;					      \
-    if (u > (x))							      \
-      u -= 1;								      \
-    (r) = u;								      \
-    (x) -= u;								      \
-  })
-
-/* Align IN down to a multiple of F, where F is a power of two.  */
-#define ALIGN_DOWN_TO(in, f) \
-  ({									      \
-    double factor = f * TWO52;						      \
-    double u = (in + factor) - factor;					      \
-    if (u > in)								      \
-      u -= f;								      \
-    u;									      \
-  })
diff --git a/sysdeps/powerpc/power4/fpu/mpa.c b/sysdeps/powerpc/power4/fpu/mpa.c
deleted file mode 100644
index 1be2e93cb7..0000000000
--- a/sysdeps/powerpc/power4/fpu/mpa.c
+++ /dev/null
@@ -1,214 +0,0 @@
-
-/*
- * IBM Accurate Mathematical Library
- * written by International Business Machines Corp.
- * Copyright (C) 2001-2019 Free Software Foundation, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/* Define __mul and __sqr and use the rest from generic code.  */
-#define NO__MUL
-#define NO__SQR
-
-#include <sysdeps/ieee754/dbl-64/mpa.c>
-
-/* Multiply *X and *Y and store result in *Z.  X and Y may overlap but not X
-   and Z or Y and Z.  For P in [1, 2, 3], the exact result is truncated to P
-   digits.  In case P > 3 the error is bounded by 1.001 ULP.  */
-void
-__mul (const mp_no *x, const mp_no *y, mp_no *z, int p)
-{
-  long i, i1, i2, j, k, k2;
-  long p2 = p;
-  double u, zk, zk2;
-
-  /* Is z=0?  */
-  if (__glibc_unlikely (X[0] * Y[0] == 0))
-    {
-      Z[0] = 0;
-      return;
-    }
-
-  /* Multiply, add and carry */
-  k2 = (p2 < 3) ? p2 + p2 : p2 + 3;
-  zk = Z[k2] = 0;
-  for (k = k2; k > 1;)
-    {
-      if (k > p2)
-	{
-	  i1 = k - p2;
-	  i2 = p2 + 1;
-	}
-      else
-	{
-	  i1 = 1;
-	  i2 = k;
-	}
-#if 1
-      /* Rearrange this inner loop to allow the fmadd instructions to be
-         independent and execute in parallel on processors that have
-         dual symmetrical FP pipelines.  */
-      if (i1 < (i2 - 1))
-	{
-	  /* Make sure we have at least 2 iterations.  */
-	  if (((i2 - i1) & 1L) == 1L)
-	    {
-	      /* Handle the odd iterations case.  */
-	      zk2 = x->d[i2 - 1] * y->d[i1];
-	    }
-	  else
-	    zk2 = 0.0;
-	  /* Do two multiply/adds per loop iteration, using independent
-	     accumulators; zk and zk2.  */
-	  for (i = i1, j = i2 - 1; i < i2 - 1; i += 2, j -= 2)
-	    {
-	      zk += x->d[i] * y->d[j];
-	      zk2 += x->d[i + 1] * y->d[j - 1];
-	    }
-	  zk += zk2;		/* Final sum.  */
-	}
-      else
-	{
-	  /* Special case when iterations is 1.  */
-	  zk += x->d[i1] * y->d[i1];
-	}
-#else
-      /* The original code.  */
-      for (i = i1, j = i2 - 1; i < i2; i++, j--)
-	zk += X[i] * Y[j];
-#endif
-
-      u = (zk + CUTTER) - CUTTER;
-      if (u > zk)
-	u -= RADIX;
-      Z[k] = zk - u;
-      zk = u * RADIXI;
-      --k;
-    }
-  Z[k] = zk;
-
-  int e = EX + EY;
-  /* Is there a carry beyond the most significant digit?  */
-  if (Z[1] == 0)
-    {
-      for (i = 1; i <= p2; i++)
-	Z[i] = Z[i + 1];
-      e--;
-    }
-
-  EZ = e;
-  Z[0] = X[0] * Y[0];
-}
-
-/* Square *X and store result in *Y.  X and Y may not overlap.  For P in
-   [1, 2, 3], the exact result is truncated to P digits.  In case P > 3 the
-   error is bounded by 1.001 ULP.  This is a faster special case of
-   multiplication.  */
-void
-__sqr (const mp_no *x, mp_no *y, int p)
-{
-  long i, j, k, ip;
-  double u, yk;
-
-  /* Is z=0?  */
-  if (__glibc_unlikely (X[0] == 0))
-    {
-      Y[0] = 0;
-      return;
-    }
-
-  /* We need not iterate through all X's since it's pointless to
-     multiply zeroes.  */
-  for (ip = p; ip > 0; ip--)
-    if (X[ip] != 0)
-      break;
-
-  k = (__glibc_unlikely (p < 3)) ? p + p : p + 3;
-
-  while (k > 2 * ip + 1)
-    Y[k--] = 0;
-
-  yk = 0;
-
-  while (k > p)
-    {
-      double yk2 = 0.0;
-      long lim = k / 2;
-
-      if (k % 2 == 0)
-        {
-	  yk += X[lim] * X[lim];
-	  lim--;
-	}
-
-      /* In __mul, this loop (and the one within the next while loop) run
-         between a range to calculate the mantissa as follows:
-
-         Z[k] = X[k] * Y[n] + X[k+1] * Y[n-1] ... + X[n-1] * Y[k+1]
-		+ X[n] * Y[k]
-
-         For X == Y, we can get away with summing halfway and doubling the
-	 result.  For cases where the range size is even, the mid-point needs
-	 to be added separately (above).  */
-      for (i = k - p, j = p; i <= lim; i++, j--)
-	yk2 += X[i] * X[j];
-
-      yk += 2.0 * yk2;
-
-      u = (yk + CUTTER) - CUTTER;
-      if (u > yk)
-	u -= RADIX;
-      Y[k--] = yk - u;
-      yk = u * RADIXI;
-    }
-
-  while (k > 1)
-    {
-      double yk2 = 0.0;
-      long lim = k / 2;
-
-      if (k % 2 == 0)
-        {
-	  yk += X[lim] * X[lim];
-	  lim--;
-	}
-
-      /* Likewise for this loop.  */
-      for (i = 1, j = k - 1; i <= lim; i++, j--)
-	yk2 += X[i] * X[j];
-
-      yk += 2.0 * yk2;
-
-      u = (yk + CUTTER) - CUTTER;
-      if (u > yk)
-	u -= RADIX;
-      Y[k--] = yk - u;
-      yk = u * RADIXI;
-    }
-  Y[k] = yk;
-
-  /* Squares are always positive.  */
-  Y[0] = 1.0;
-
-  int e = EX * 2;
-  /* Is there a carry beyond the most significant digit?  */
-  if (__glibc_unlikely (Y[1] == 0))
-    {
-      for (i = 1; i <= p; i++)
-	Y[i] = Y[i + 1];
-      e--;
-    }
-  EY = e;
-}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 04/28] powerpc: ceil/ceilf refactor
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 03/28] powerpc: Remove power4 mpa optimization Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-04-25  1:56   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 05/28] powerpc: floor/floorf refactor Adhemerval Zanella
                   ` (23 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc ceil{f} implementations on
the generic sysdeps/powerpc/fpu/s_ceil{f}.  The generic implementation
uses either the compiler builts for ISA 2.03+ (which generates the frip
instruction) or a generic implementation which uses FP only operations.

It adds a generic implementation (round_to_integer.h) which is shared
with other rounding to integer routines.  The resulting code should be
similar performance-wise to previous assembly one.

The IFUNC organization for powerpc64 is also change to be enabled only
for powerpc64 and not for powerpc64le.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/fenv_libc.h (__fesetround_inline_nocheck): New
	macro.
	* sysdeps/powerpc/fpu/round_to_integer.h: New file.
	* sysdeps/powerpc/fpu/s_ceil.c: Likewise.
	* sysdeps/powerpc/fpu/s_ceilf.c: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_ceil.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_ceilf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
	(CFLAGS-s_ceil-power5+.c, CFLAGS-s_ceilf-power5+.c): New rule.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.S:
	Remove file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.c:
	New file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S: Remove file.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S: Likewise.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile: New file.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-power5+.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil.c: ... here.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-power5+.c: New
	file.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf.c: ...
	* here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove s_ceil-power5+, s_ceil-ppc64,
	s_ceilf-power5+, and s_ceilf-ppc64.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-power5+.S: Remove
	file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-power5+.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_ceil.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S: Likewise.
---
 sysdeps/powerpc/fpu/fenv_libc.h               |   8 ++
 sysdeps/powerpc/fpu/round_to_integer.h        | 109 ++++++++++++++++++
 sysdeps/powerpc/fpu/s_ceil.c                  |  35 ++++++
 sysdeps/powerpc/fpu/s_ceilf.c                 |  35 ++++++
 sysdeps/powerpc/powerpc32/fpu/s_ceil.S        |  76 ------------
 sysdeps/powerpc/powerpc32/fpu/s_ceilf.S       |  76 ------------
 .../powerpc32/power4/fpu/multiarch/Makefile   |   2 +
 .../power4/fpu/multiarch/s_ceil-power5+.S     |  33 ------
 .../power4/fpu/multiarch/s_ceil-power5+.c     |   3 +
 .../power4/fpu/multiarch/s_ceil-ppc32.S       |  31 -----
 .../power4/fpu/multiarch/s_ceil-ppc32.c       |   3 +
 .../power4/fpu/multiarch/s_ceilf-power5+.S    |  26 -----
 .../power4/fpu/multiarch/s_ceilf-power5+.c    |   3 +
 .../power4/fpu/multiarch/s_ceilf-ppc32.S      |  27 -----
 .../power4/fpu/multiarch/s_ceilf-ppc32.c      |   3 +
 .../powerpc/powerpc32/power5+/fpu/s_ceil.S    |  29 -----
 .../powerpc/powerpc32/power5+/fpu/s_ceilf.S   |  30 -----
 .../powerpc64/be/fpu/multiarch/Makefile       |   9 ++
 .../be/fpu/multiarch/s_ceil-power5+.c         |   3 +
 .../powerpc64/be/fpu/multiarch/s_ceil-ppc64.c |   3 +
 .../powerpc64/{ => be}/fpu/multiarch/s_ceil.c |   4 +-
 .../be/fpu/multiarch/s_ceilf-power5+.c        |   3 +
 .../be/fpu/multiarch/s_ceilf-ppc64.c          |   3 +
 .../{ => be}/fpu/multiarch/s_ceilf.c          |   4 +-
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |   3 +-
 .../powerpc64/fpu/multiarch/s_ceil-power5+.S  |  30 -----
 .../powerpc64/fpu/multiarch/s_ceil-ppc64.S    |  30 -----
 .../powerpc64/fpu/multiarch/s_ceilf-power5+.S |  24 ----
 .../powerpc64/fpu/multiarch/s_ceilf-ppc64.S   |  24 ----
 sysdeps/powerpc/powerpc64/fpu/s_ceil.S        |  65 -----------
 sysdeps/powerpc/powerpc64/fpu/s_ceilf.S       |  67 -----------
 .../powerpc/powerpc64/power5+/fpu/s_ceil.S    |  30 -----
 .../powerpc/powerpc64/power5+/fpu/s_ceilf.S   |  31 -----
 33 files changed, 225 insertions(+), 637 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/round_to_integer.h
 create mode 100644 sysdeps/powerpc/fpu/s_ceil.c
 create mode 100644 sysdeps/powerpc/fpu/s_ceilf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_ceilf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_ceil.c (95%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_ceilf.c (95%)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_ceilf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S

diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
index 67a9c9a51a..01dccb15a8 100644
--- a/sysdeps/powerpc/fpu/fenv_libc.h
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
@@ -98,6 +98,14 @@ __fesetround_inline (int round)
   return 0;
 }
 
+/* Same as __fesetround_inline, however without runtime check to use DFP
+   mtfsfi syntax or if round is valid.  */
+static inline void
+__fesetround_inline_nocheck (const int round)
+{
+  asm volatile ("mtfsfi 7,%0" : : "i" (round));
+}
+
 /* Definitions of all the FPSCR bit numbers */
 enum {
   FPSCR_FX = 0,    /* exception summary */
diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
new file mode 100644
index 0000000000..417aae6242
--- /dev/null
+++ b/sysdeps/powerpc/fpu/round_to_integer.h
@@ -0,0 +1,109 @@
+/* Round to integer generic implementation.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _ROUND_TO_INTEGER_H
+#define _ROUND_TO_INTEGER_H
+
+#include <fenv_private.h>
+
+enum round_mode
+{
+  CEIL,
+  FLOOR,
+  ROUND,
+  TRUNC,
+  NEARBYINT,
+};
+
+static inline void
+set_fenv_mode (enum round_mode mode)
+{
+  int rmode;
+  switch (mode)
+  {
+  case CEIL:  rmode = FE_UPWARD; break;
+  default:    rmode = FE_TONEAREST; break;
+  }
+  __fesetround_inline_nocheck (rmode);
+}
+
+static inline float
+round_to_integer_float (enum round_mode mode, float x)
+{
+  /* Ensure sNaN input is converted to qNaN.  */
+  if (__glibc_unlikely (isnan (x)))
+    return x + x;
+
+  if (fabs (x) > 0x1p+23)
+    return x;
+
+  float r = x;
+
+  /* Save current FPU rounding mode and inexact state.  */
+  fenv_t fe = fegetenv_register ();
+  set_fenv_mode (mode);
+  if (x > 0.0)
+    {
+      r += 0x1p+23;
+      r -= 0x1p+23;
+      r = fabs (r);
+    }
+  else if (x < 0.0)
+    {
+      r -= 0x1p+23;
+      r += 0x1p+23;
+      r = -fabs (r);
+    }
+  __builtin_mtfsf (0xff, fe);
+
+  return r;
+}
+
+static inline double
+round_to_integer_double (enum round_mode mode, double x)
+{
+  /* Ensure sNaN input is converted to qNaN.  */
+  if (__glibc_unlikely (isnan (x)))
+    return x + x;
+
+  if (fabs (x) > 0x1p+52)
+    return x;
+
+  double r = x;
+
+  /* Save current FPU rounding mode and inexact state.  */
+  fenv_t fe = fegetenv_register ();
+  set_fenv_mode (mode);
+  if (x > 0.0)
+    {
+      r += 0x1p+52;
+      r -= 0x1p+52;
+      r = fabs (r);
+    }
+  else if (x < 0.0)
+    {
+      r -= 0x1p+52;
+      r += 0x1p+52;
+      r = -fabs (r);
+    }
+  __builtin_mtfsf (0xff, fe);
+
+  return r;
+}
+
+#endif
diff --git a/sysdeps/powerpc/fpu/s_ceil.c b/sysdeps/powerpc/fpu/s_ceil.c
new file mode 100644
index 0000000000..49008c7af8
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_ceil.c
@@ -0,0 +1,35 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-double.h>
+#include <round_to_integer.h>
+
+double
+__ceil (double x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_ceil (x);
+#else
+  return round_to_integer_double (CEIL, x);
+#endif
+}
+#ifndef __ceil
+libm_alias_double (__ceil, ceil)
+#endif
diff --git a/sysdeps/powerpc/fpu/s_ceilf.c b/sysdeps/powerpc/fpu/s_ceilf.c
new file mode 100644
index 0000000000..8c86bf30a3
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_ceilf.c
@@ -0,0 +1,35 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-float.h>
+#include <round_to_integer.h>
+
+float
+__ceilf (float x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_ceilf (x);
+#else
+  return round_to_integer_float (CEIL, x);
+#endif
+}
+#ifndef __ceilf
+libm_alias_float (__ceil, ceil)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_ceil.S b/sysdeps/powerpc/powerpc32/fpu/s_ceil.S
deleted file mode 100644
index 4d0fdad2c1..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_ceil.S
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ceil function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**52 */
-	.long 0x59800000
-
-	.section	".text"
-ENTRY (__ceil)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,2		/* Set rounding mode toward +inf.  */
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__ceil)
-
-libm_alias_double (__ceil, ceil)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_ceilf.S b/sysdeps/powerpc/powerpc32/fpu/s_ceilf.S
deleted file mode 100644
index c32044afa6..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_ceilf.S
+++ /dev/null
@@ -1,76 +0,0 @@
-/* float ceil function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-
-	.section	".text"
-ENTRY (__ceilf)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,2		/* Set rounding mode toward +inf.  */
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__ceilf)
-
-libm_alias_float (__ceil, ceil)
-
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index 4e85021d50..cf38e347f2 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -26,6 +26,8 @@ libm-sysdep_routines += s_llrintf-power6 s_llrintf-ppc32 s_llrint-power6 \
 			s_logbf-power7 s_logbf-ppc32 e_hypot-power7 \
 			e_hypot-ppc32 e_hypotf-power7 e_hypotf-ppc32
 
+CFLAGS-s_ceil-power5+.c = -mcpu=power5+
+CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
 CFLAGS-s_modf-power5+.c = -mcpu=power5+
 CFLAGS-s_modff-power5+.c = -mcpu=power5+
 CFLAGS-s_logbl-power7.c = -mcpu=power7
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.S
deleted file mode 100644
index b13a56667e..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ceil function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __ceil __ceil_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.c
new file mode 100644
index 0000000000..87bc66cdb0
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceil __ceil_power5plus
+#include <sysdeps/powerpc/fpu/s_ceil.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.S
deleted file mode 100644
index 899dc140c6..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ceil function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __ceil __ceil_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_ceil.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.c
new file mode 100644
index 0000000000..93c098476b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceil __ceil_ppc32
+#include <sysdeps/powerpc/fpu/s_ceil.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.S
deleted file mode 100644
index 6279638031..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ceilf function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef weak_alias
-#define weak_alias(name, alias)
-
-#define __ceilf __ceilf_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.c
new file mode 100644
index 0000000000..a5bfa98535
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceilf __ceilf_power5plus
+#include <sysdeps/powerpc/fpu/s_ceilf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.S
deleted file mode 100644
index a84edf7a5b..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ceilf function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __ceilf __ceilf_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_ceilf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.c
new file mode 100644
index 0000000000..a4dcdcb406
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceilf __ceilf_ppc32
+#include <sysdeps/powerpc/fpu/s_ceilf.c>
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S
deleted file mode 100644
index 7dab4023f7..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ceil function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-EALIGN (__ceil, 4, 0)
-	frip	fp1, fp1
-	blr
-	END (__ceil)
-
-libm_alias_double (__ceil, ceil)
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S
deleted file mode 100644
index 15a6f27d28..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ceilf function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-EALIGN (__ceilf, 4, 0)
-	frip	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__ceilf)
-
-libm_alias_float (__ceil, ceil)
-
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
new file mode 100644
index 0000000000..932c3c7e6c
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -0,0 +1,9 @@
+ifeq ($(subdir),math)
+libm-sysdep_routines += s_ceil-power5+ \
+			s_ceil-ppc64 \
+			s_ceilf-power5+ \
+			s_ceilf-ppc64
+
+CFLAGS-s_ceil-power5+.c = -mcpu=power5+
+CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
+endif
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-power5+.c
new file mode 100644
index 0000000000..87bc66cdb0
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceil __ceil_power5plus
+#include <sysdeps/powerpc/fpu/s_ceil.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-ppc64.c
new file mode 100644
index 0000000000..8711ff3229
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceil __ceil_ppc64
+#include <sysdeps/powerpc/fpu/s_ceil.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil.c
similarity index 95%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil.c
index b72f4b1cc0..36976a0404 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil.c
@@ -18,10 +18,8 @@
 
 #define NO_MATH_REDIRECT
 #include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
 #include <libm-alias-double.h>
+#include "init-arch.h"
 
 extern __typeof (__ceil) __ceil_ppc64 attribute_hidden;
 extern __typeof (__ceil) __ceil_power5plus attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-power5+.c
new file mode 100644
index 0000000000..a5bfa98535
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceilf __ceilf_power5plus
+#include <sysdeps/powerpc/fpu/s_ceilf.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-ppc64.c
new file mode 100644
index 0000000000..086251dc09
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __ceilf __ceilf_ppc64
+#include <sysdeps/powerpc/fpu/s_ceilf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf.c
similarity index 95%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf.c
index 707f07c0bb..34811330d5 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf.c
@@ -18,10 +18,8 @@
 
 #define NO_MATH_REDIRECT
 #include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
 #include <libm-alias-float.h>
+#include "init-arch.h"
 
 extern __typeof (__ceilf) __ceilf_ppc64 attribute_hidden;
 extern __typeof (__ceilf) __ceilf_power5plus attribute_hidden;
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 39b557604c..ac6d162f91 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -14,8 +14,7 @@ sysdep_calls := s_copysign-power6 s_copysign-ppc64 \
 
 sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_llround-power6x \
-			s_llround-power5+ s_llround-ppc64 s_ceil-power5+ \
-			s_ceil-ppc64 s_ceilf-power5+ s_ceilf-ppc64 \
+			s_llround-power5+ s_llround-ppc64 \
 			s_floor-power5+ s_floor-ppc64 s_floorf-power5+ \
 			s_floorf-ppc64 s_round-power5+ s_round-ppc64 \
 			s_roundf-power5+ s_roundf-ppc64 s_trunc-power5+ \
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-power5+.S
deleted file mode 100644
index 8782e6378e..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-power5+.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ceil function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __ceil __ceil_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-ppc64.S
deleted file mode 100644
index 5d9b30d50d..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-ppc64.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ceil function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __ceil __ceil_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_ceil.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-power5+.S
deleted file mode 100644
index 6c9d18880e..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-power5+.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* ceilf function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __ceilf __ceilf_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-ppc64.S
deleted file mode 100644
index 2aaa8c4e4a..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-ppc64.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* ceilf function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __ceilf __ceilf_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_ceilf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_ceil.S b/sysdeps/powerpc/powerpc64/fpu/s_ceil.S
deleted file mode 100644
index 3e0a968abe..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_ceil.S
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ceil function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	".toc","aw"
-.LC0:	/* 2**52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-	.section	".text"
-
-ENTRY (__ceil, 4)
-	CALL_MCOUNT 0
-	lfd	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,2		/* Set rounding mode toward +inf.  */
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__ceil)
-
-libm_alias_double (__ceil, ceil)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_ceilf.S b/sysdeps/powerpc/powerpc64/fpu/s_ceilf.S
deleted file mode 100644
index a189f9fd58..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_ceilf.S
+++ /dev/null
@@ -1,67 +0,0 @@
-/* float ceil function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	".toc","aw"
-	.p2align 3
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-	.long 0x0
-	.section	".text"
-
-ENTRY (__ceilf, 4)
-	CALL_MCOUNT 0
-	lfs	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,2		/* Set rounding mode toward +inf.  */
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__ceilf)
-
-libm_alias_float (__ceil, ceil)
-
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S
deleted file mode 100644
index 8feb687697..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ceil function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__ceil, 4)
-	CALL_MCOUNT 0
-	frip	fp1, fp1
-	blr
-	END (__ceil)
-
-libm_alias_double (__ceil, ceil)
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S
deleted file mode 100644
index 11d13abd11..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ceilf function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__ceilf, 4)
-	CALL_MCOUNT 0
-	frip	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__ceilf)
-
-libm_alias_float (__ceil, ceil)
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 05/28] powerpc: floor/floorf refactor
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 04/28] powerpc: ceil/ceilf refactor Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-05-03 21:44   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 06/28] powerpc: round/roundf refactor Adhemerval Zanella
                   ` (22 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc floor{f} implementations on
the generic sysdeps/powerpc/fpu/s_floor{f}.  The generic implementation
uses either the compiler builts for ISA 2.03+ (which generates the
frim instruction) or a generic implementation which uses FP only
operations.

The IFUNC organization for powerpc64 is also change to be enabled only
for powerpc64 and not for powerpc64le.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/round_to_integer.h (set_rounding_mode):
	Add FLOOR option.
	* sysdeps/powerpc/fpu/s_floor.c: New file.
	* sysdeps/powerpc/fpu/s_floorf.c: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_floor.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_floorf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.S:
	Remove file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.S:
	Likewise
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.c:
	New file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_floor.S: Remove file.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S: Remove file.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
	(libm-sysdep_routines): Add s_floor-power5+, s_floor-ppc64,
	s_floorf-power5+, and s_floorf-ppc64.
	(CFLAGS-s_floor-power5+.c, CFLAGS-s_floorf-power5+.c): New rule.
	* sysdep/powerpc/powerpc64/be/fpu/multiarch/s_floor-power5+.c: New
	file.
	* sysdep/powerpc/powerpc64/be/fpu/multiarch/s_floor-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor.c: ... here.
	* sysdep/powerpc/powerpc64/be/fpu/multiarch/s_floorf-power5+.c: New
	file.
	* sysdep/powerpc/powerpc64/be/fpu/multiarch/s_floorf-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove s_floor-power5+, s_floor-ppc64,
	s_floorf-power5+, and s_floorf-ppc64.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_floor-power5+.S: Remove
	file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-ppc64.S: Remove
	file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-power5+.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-ppc64.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_floor.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_floorf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S: Likewise.
---
 sysdeps/powerpc/fpu/round_to_integer.h        |  1 +
 sysdeps/powerpc/fpu/s_floor.c                 | 35 +++++++++
 sysdeps/powerpc/fpu/s_floorf.c                | 35 +++++++++
 sysdeps/powerpc/powerpc32/fpu/s_floor.S       | 76 -------------------
 sysdeps/powerpc/powerpc32/fpu/s_floorf.S      | 76 -------------------
 .../power4/fpu/multiarch/s_floor-power5+.S    | 33 --------
 .../power4/fpu/multiarch/s_floor-power5+.c    |  3 +
 .../power4/fpu/multiarch/s_floor-ppc32.S      | 31 --------
 .../power4/fpu/multiarch/s_floor-ppc32.c      |  3 +
 .../power4/fpu/multiarch/s_floorf-power5+.S   | 26 -------
 .../power4/fpu/multiarch/s_floorf-power5+.c   |  3 +
 .../power4/fpu/multiarch/s_floorf-ppc32.S     | 27 -------
 .../power4/fpu/multiarch/s_floorf-ppc32.c     |  3 +
 .../powerpc/powerpc32/power5+/fpu/s_floor.S   | 29 -------
 .../powerpc/powerpc32/power5+/fpu/s_floorf.S  | 30 --------
 .../powerpc64/be/fpu/multiarch/Makefile       |  8 +-
 .../be/fpu/multiarch/s_floor-power5+.c        |  3 +
 .../be/fpu/multiarch/s_floor-ppc64.c          |  3 +
 .../{ => be}/fpu/multiarch/s_floor.c          |  0
 .../be/fpu/multiarch/s_floorf-power5+.c       |  3 +
 .../be/fpu/multiarch/s_floorf-ppc64.c         |  3 +
 .../{ => be}/fpu/multiarch/s_floorf.c         |  0
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  3 +-
 .../powerpc64/fpu/multiarch/s_floor-power5+.S | 30 --------
 .../powerpc64/fpu/multiarch/s_floor-ppc64.S   | 30 --------
 .../fpu/multiarch/s_floorf-power5+.S          | 24 ------
 .../powerpc64/fpu/multiarch/s_floorf-ppc64.S  | 24 ------
 sysdeps/powerpc/powerpc64/fpu/s_floor.S       | 65 ----------------
 sysdeps/powerpc/powerpc64/fpu/s_floorf.S      | 67 ----------------
 .../powerpc/powerpc64/power5+/fpu/s_floor.S   | 30 --------
 .../powerpc/powerpc64/power5+/fpu/s_floorf.S  | 31 --------
 31 files changed, 103 insertions(+), 632 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/s_floor.c
 create mode 100644 sysdeps/powerpc/fpu/s_floorf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_floorf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_floor.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_floorf.c (100%)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_floorf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S

diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
index 417aae6242..77d9fc1f86 100644
--- a/sysdeps/powerpc/fpu/round_to_integer.h
+++ b/sysdeps/powerpc/fpu/round_to_integer.h
@@ -37,6 +37,7 @@ set_fenv_mode (enum round_mode mode)
   switch (mode)
   {
   case CEIL:  rmode = FE_UPWARD; break;
+  case FLOOR: rmode = FE_DOWNWARD; break;
   default:    rmode = FE_TONEAREST; break;
   }
   __fesetround_inline_nocheck (rmode);
diff --git a/sysdeps/powerpc/fpu/s_floor.c b/sysdeps/powerpc/fpu/s_floor.c
new file mode 100644
index 0000000000..fb8df97cca
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_floor.c
@@ -0,0 +1,35 @@
+/* Largest integral value not greater than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-double.h>
+#include <round_to_integer.h>
+
+double
+__floor (double x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_floor (x);
+#else
+  return round_to_integer_double (FLOOR, x);
+#endif
+}
+#ifndef __floor
+libm_alias_double (__floor, floor)
+#endif
diff --git a/sysdeps/powerpc/fpu/s_floorf.c b/sysdeps/powerpc/fpu/s_floorf.c
new file mode 100644
index 0000000000..ea4723bb69
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_floorf.c
@@ -0,0 +1,35 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-float.h>
+#include <round_to_integer.h>
+
+float
+__floorf (float x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_floorf (x);
+#else
+  return round_to_integer_float (FLOOR, x);
+#endif
+}
+#ifndef __floorf
+libm_alias_float (__floor, floor)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_floor.S b/sysdeps/powerpc/powerpc32/fpu/s_floor.S
deleted file mode 100644
index 3b6492e242..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_floor.S
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Floor function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**52 */
-	.long 0x59800000
-
-	.section	".text"
-ENTRY (__floor)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,3		/* Set rounding mode toward -inf.  */
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__floor)
-
-libm_alias_double (__floor, floor)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_floorf.S b/sysdeps/powerpc/powerpc32/fpu/s_floorf.S
deleted file mode 100644
index 907271e031..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_floorf.S
+++ /dev/null
@@ -1,76 +0,0 @@
-/* float Floor function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-
-	.section	".text"
-ENTRY (__floorf)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,3		/* Set rounding mode toward -inf.  */
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__floorf)
-
-libm_alias_float (__floor, floor)
-
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.S
deleted file mode 100644
index 03babf644c..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* floor function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __floor __floor_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_floor.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.c
new file mode 100644
index 0000000000..d3c2f52e57
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floor __floor_power5plus
+#include <sysdeps/powerpc/fpu/s_floor.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.S
deleted file mode 100644
index 296646109b..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* floor function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __floor __floor_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_floor.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.c
new file mode 100644
index 0000000000..9decd0faf8
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floor __floor_ppc32
+#include <sysdeps/powerpc/fpu/s_floor.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.S
deleted file mode 100644
index 47a1a18d16..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/* floorf function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef weak_alias
-#define weak_alias(name, alias)
-
-#define __floorf __floorf_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.c
new file mode 100644
index 0000000000..ecc409580b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floorf __floorf_power5plus
+#include <sysdeps/powerpc/fpu/s_floorf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.S
deleted file mode 100644
index bce86ab0d3..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/* floorf function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __floorf __floorf_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_floorf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.c
new file mode 100644
index 0000000000..ba1d8f4d55
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floorf __floorf_ppc32
+#include <sysdeps/powerpc/fpu/s_floorf.c>
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_floor.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_floor.S
deleted file mode 100644
index 55d88e601a..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_floor.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/* floor function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-EALIGN (__floor, 4, 0)
-	frim	fp1, fp1
-	blr
-	END (__floor)
-
-libm_alias_double (__floor, floor)
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S
deleted file mode 100644
index e45c358cdd..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* floorf function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-EALIGN (__floorf, 4, 0)
-	frim	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__floorf)
-
-libm_alias_float (__floor, floor)
-
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index 932c3c7e6c..8bb06e5cc0 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -2,8 +2,14 @@ ifeq ($(subdir),math)
 libm-sysdep_routines += s_ceil-power5+ \
 			s_ceil-ppc64 \
 			s_ceilf-power5+ \
-			s_ceilf-ppc64
+			s_ceilf-ppc64 \
+			s_floor-power5+ \
+			s_floor-ppc64 \
+			s_floorf-power5+ \
+			s_floorf-ppc64
 
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
+CFLAGS-s_floor-power5+.c = -mcpu=power5+
+CFLAGS-s_floorf-power5+.c = -mcpu=power5+
 endif
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-power5+.c
new file mode 100644
index 0000000000..d3c2f52e57
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floor __floor_power5plus
+#include <sysdeps/powerpc/fpu/s_floor.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-ppc64.c
new file mode 100644
index 0000000000..92c072c886
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floor __floor_ppc64
+#include <sysdeps/powerpc/fpu/s_floor.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floor.c
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-power5+.c
new file mode 100644
index 0000000000..ecc409580b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floorf __floorf_power5plus
+#include <sysdeps/powerpc/fpu/s_floorf.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-ppc64.c
new file mode 100644
index 0000000000..ad657ecfc4
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __floorf __floorf_ppc64
+#include <sysdeps/powerpc/fpu/s_floorf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_floorf.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index ac6d162f91..8a73108e4c 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -15,8 +15,7 @@ sysdep_calls := s_copysign-power6 s_copysign-ppc64 \
 sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_llround-power6x \
 			s_llround-power5+ s_llround-ppc64 \
-			s_floor-power5+ s_floor-ppc64 s_floorf-power5+ \
-			s_floorf-ppc64 s_round-power5+ s_round-ppc64 \
+			s_round-power5+ s_round-ppc64 \
 			s_roundf-power5+ s_roundf-ppc64 s_trunc-power5+ \
 			s_trunc-ppc64 s_truncf-power5+ s_truncf-ppc64 \
 			s_llrint-power6x s_llrint-ppc64 \
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-power5+.S
deleted file mode 100644
index f4917d5f57..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-power5+.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* floor function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __floor __floor_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-ppc64.S
deleted file mode 100644
index 982d4a1b7f..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor-ppc64.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* floor function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __floor __floor_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_floor.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-power5+.S
deleted file mode 100644
index 01a15e4e55..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-power5+.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* floorf function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __floorf __floorf_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-ppc64.S
deleted file mode 100644
index 2b31a96c86..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf-ppc64.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* floorf function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __floorf __floorf_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_floorf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_floor.S b/sysdeps/powerpc/powerpc64/fpu/s_floor.S
deleted file mode 100644
index 78cacd88ca..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_floor.S
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Floor function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	".toc","aw"
-.LC0:	/* 2**52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-	.section	".text"
-
-ENTRY (__floor, 4)
-	CALL_MCOUNT 0
-	lfd	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,3		/* Set rounding mode toward -inf.  */
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__floor)
-
-libm_alias_double (__floor, floor)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_floorf.S b/sysdeps/powerpc/powerpc64/fpu/s_floorf.S
deleted file mode 100644
index ba2ba3b293..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_floorf.S
+++ /dev/null
@@ -1,67 +0,0 @@
-/* float Floor function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	".toc","aw"
-	.p2align 3
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-	.long 0x0
-	.section	".text"
-
-ENTRY (__floorf, 4)
-	CALL_MCOUNT 0
-	lfs	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,3		/* Set rounding mode toward -inf.  */
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__floorf)
-
-libm_alias_float (__floor, floor)
-
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S
deleted file mode 100644
index 6ddaf21862..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* floor function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__floor, 4)
-	CALL_MCOUNT 0
-	frim	fp1, fp1
-	blr
-	END (__floor)
-
-libm_alias_double (__floor, floor)
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S
deleted file mode 100644
index b43f7a27e6..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* floorf function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__floorf, 4)
-	CALL_MCOUNT 0
-	frim	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__floorf)
-
-libm_alias_float (__floor, floor)
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 06/28] powerpc: round/roundf refactor
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 05/28] powerpc: floor/floorf refactor Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-05-04  1:10   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 07/28] powerpc: trunc/truncf refactor Adhemerval Zanella
                   ` (21 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc round{f} implementations on
the generic sysdeps/powerpc/fpu/s_round{f}.  The generic implementation
uses either the compiler builts for ISA 2.03+ (which generates the
frim instruction) or a generic implementation which uses FP only
operations.

The IFUNC organization for powerpc64 is also change to be enabled only
for powerpc64 and not for powerpc64le.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/round_to_integer.h (set_rounding_mode): Add
	ROUND handling.
	(round_to_integer_float): Likewise.
	* sysdeps/powerpc/fpu/s_round.c: New file.
	* sysdeps/powerpc/fpu/s_roundf.c: New file.
	* sysdeps/powerpc/powerpc32/fpu/s_round.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_roundf.S: Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-power5+.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-ppc32.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-power5+.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-ppc32.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-power5+.c: New
	file.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-ppc32.c:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-power5+.c:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-ppc32.c:
	Likewise.
	* sysdep/powerpc/powerpc32/power5+/fpu/s_round.S: Remove file.
	* sysdep/powerpc/powerpc32/power5+/fpu/s_roundf.S: Likewise.
	* sysdep/powerpc/powerpc64/be/fpu/multiarch/Makefile
	(libm-sysdep_routines): Add s_round-power5+, s_round-ppc64,
	s_roundf-power5+, and s_roundf-ppc64.
	(CFLAGS-s_round-power5+.c, CFLAGS-s_roundf-power5+.c): New rule.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_round-power5+.c: New
	file.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_round-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round.c: ... here.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_roundf-power5+.c: New
	file.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_roundf-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove s_round-power5+, s_round-ppc64,
	s_roundf-power5+, and s_roundf-ppc64.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S: Remove
	file.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S: Likewise.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S:
	Likewise.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_round.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_roundf.S: Likewise.
	* sysdep/powerpc/powerpc64/power5+/fpu/s_round.S: Likewise.
	* sysdep/powerpc/powerpc64/power5+/fpu/s_roundf.S: Likewise.
---
 sysdeps/powerpc/fpu/round_to_integer.h        | 17 ++++
 sysdeps/powerpc/fpu/s_round.c                 | 35 +++++++
 sysdeps/powerpc/fpu/s_roundf.c                | 35 +++++++
 sysdeps/powerpc/powerpc32/fpu/s_round.S       | 97 -------------------
 sysdeps/powerpc/powerpc32/fpu/s_roundf.S      | 96 ------------------
 .../power4/fpu/multiarch/s_round-power5+.S    | 33 -------
 .../power4/fpu/multiarch/s_round-power5+.c    |  3 +
 .../power4/fpu/multiarch/s_round-ppc32.S      | 31 ------
 .../power4/fpu/multiarch/s_round-ppc32.c      |  3 +
 .../power4/fpu/multiarch/s_roundf-power5+.S   | 26 -----
 .../power4/fpu/multiarch/s_roundf-power5+.c   |  3 +
 .../power4/fpu/multiarch/s_roundf-ppc32.S     | 27 ------
 .../power4/fpu/multiarch/s_roundf-ppc32.c     |  3 +
 .../powerpc/powerpc32/power5+/fpu/s_round.S   | 29 ------
 .../powerpc/powerpc32/power5+/fpu/s_roundf.S  | 30 ------
 .../powerpc64/be/fpu/multiarch/Makefile       |  8 +-
 .../be/fpu/multiarch/s_round-power5+.c        |  3 +
 .../be/fpu/multiarch/s_round-ppc64.c          |  3 +
 .../{ => be}/fpu/multiarch/s_round.c          |  0
 .../be/fpu/multiarch/s_roundf-power5+.c       |  3 +
 .../be/fpu/multiarch/s_roundf-ppc64.c         |  3 +
 .../{ => be}/fpu/multiarch/s_roundf.c         |  0
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  3 +-
 .../powerpc64/fpu/multiarch/s_round-power5+.S | 30 ------
 .../powerpc64/fpu/multiarch/s_round-ppc64.S   | 30 ------
 .../fpu/multiarch/s_roundf-power5+.S          | 24 -----
 .../powerpc64/fpu/multiarch/s_roundf-ppc64.S  | 24 -----
 sysdeps/powerpc/powerpc64/fpu/s_round.S       | 80 ---------------
 sysdeps/powerpc/powerpc64/fpu/s_roundf.S      | 82 ----------------
 .../powerpc/powerpc64/power5+/fpu/s_round.S   | 30 ------
 .../powerpc/powerpc64/power5+/fpu/s_roundf.S  | 31 ------
 31 files changed, 119 insertions(+), 703 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/s_round.c
 create mode 100644 sysdeps/powerpc/fpu/s_roundf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_roundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_round.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_roundf.c (100%)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_roundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S

diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
index 77d9fc1f86..3fa2b77b6d 100644
--- a/sysdeps/powerpc/fpu/round_to_integer.h
+++ b/sysdeps/powerpc/fpu/round_to_integer.h
@@ -38,6 +38,7 @@ set_fenv_mode (enum round_mode mode)
   {
   case CEIL:  rmode = FE_UPWARD; break;
   case FLOOR: rmode = FE_DOWNWARD; break;
+  case ROUND: rmode = FE_TOWARDZERO; break;
   default:    rmode = FE_TONEAREST; break;
   }
   __fesetround_inline_nocheck (rmode);
@@ -60,12 +61,24 @@ round_to_integer_float (enum round_mode mode, float x)
   set_fenv_mode (mode);
   if (x > 0.0)
     {
+      /* IEEE 1003.1 round function.  IEEE specifies "round to the nearest
+	 integer value, rounding halfway cases away from zero, regardless of
+	 the current rounding mode."  However PowerPC Architecture defines
+	 "Round to Nearest" as "Choose the best approximation. In case of a
+	 tie, choose the one that is even (least significant bit o).".
+	 So we can't use the PowerPC "Round to Nearest" mode. Instead we set
+	 "Round toward Zero" mode and round by adding +-0.5 before rounding
+	 to the integer value.  */
+      if (mode == ROUND)
+	r += 0.5f;
       r += 0x1p+23;
       r -= 0x1p+23;
       r = fabs (r);
     }
   else if (x < 0.0)
     {
+      if (mode == ROUND)
+	r -= 0.5f;
       r -= 0x1p+23;
       r += 0x1p+23;
       r = -fabs (r);
@@ -92,12 +105,16 @@ round_to_integer_double (enum round_mode mode, double x)
   set_fenv_mode (mode);
   if (x > 0.0)
     {
+      if (mode == ROUND)
+	r += 0.5;
       r += 0x1p+52;
       r -= 0x1p+52;
       r = fabs (r);
     }
   else if (x < 0.0)
     {
+      if (mode == ROUND)
+	r -= 0.5;
       r -= 0x1p+52;
       r += 0x1p+52;
       r = -fabs (r);
diff --git a/sysdeps/powerpc/fpu/s_round.c b/sysdeps/powerpc/fpu/s_round.c
new file mode 100644
index 0000000000..cd105567ef
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_round.c
@@ -0,0 +1,35 @@
+/* Largest integral value not greater than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-double.h>
+#include <round_to_integer.h>
+
+double
+__round (double x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_round (x);
+#else
+  return round_to_integer_double (ROUND, x);
+#endif
+}
+#ifndef __round
+libm_alias_double (__round, round)
+#endif
diff --git a/sysdeps/powerpc/fpu/s_roundf.c b/sysdeps/powerpc/fpu/s_roundf.c
new file mode 100644
index 0000000000..418062adba
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_roundf.c
@@ -0,0 +1,35 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-float.h>
+#include <round_to_integer.h>
+
+float
+__roundf (float x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_roundf (x);
+#else
+  return round_to_integer_float (ROUND, x);
+#endif
+}
+#ifndef __roundf
+libm_alias_float (__round, round)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_round.S b/sysdeps/powerpc/powerpc32/fpu/s_round.S
deleted file mode 100644
index 26c7516458..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_round.S
+++ /dev/null
@@ -1,97 +0,0 @@
-/* round function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	.rodata.cst8,"aM",@progbits,8
-	.align	2
-.LC0:	/* 2**52 */
-	.long 0x59800000
-.LC1:	/* 0.5 */
-	.long 0x3f000000
-
-/* double [fp1] round (double x [fp1])
-   IEEE 1003.1 round function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "Round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "Round to Nearest" mode. Instead we set
-   "Round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.  */
-
-	.section	".text"
-ENTRY (__round)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	addi	r9,r9,.LC0-got_label@l
-	mtlr	r11
-	cfi_same_value (lr)
-	lfs	fp13,0(r9)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding mode toward 0.  */
-#ifdef SHARED
-	lfs	fp10,.LC1-.LC0(r9)
-#else
-	lis	r9,.LC1@ha
-	lfs	fp10,.LC1@l(r9)
-#endif
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp10	/* x+= 0.5;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	fsub	fp9,fp1,fp10	/* x+= 0.5;  */
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp9,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__round)
-
-libm_alias_double (__round, round)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_roundf.S b/sysdeps/powerpc/powerpc32/fpu/s_roundf.S
deleted file mode 100644
index cb59a2ba51..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_roundf.S
+++ /dev/null
@@ -1,96 +0,0 @@
-/* roundf  function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	.rodata.cst8,"aM",@progbits,8
-	.align	3
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-.LC1:	/* 0.5 */
-	.long 0x3f000000
-
-/* float [fp1] roundf  (float x [fp1])
-   IEEE 1003.1 round function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "Round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "Round to Nearest" mode. Instead we set
-   "Round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.  */
-
-	.section	".text"
-ENTRY (__roundf )
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	addi	r9,r9,.LC0-got_label@l
-	mtlr	r11
-	cfi_same_value (lr)
-	lfs	fp13,0(r9)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding mode toward 0.  */
-#ifdef SHARED
-	lfs	fp10,.LC1-.LC0(r9)
-#else
-	lfs	fp10,.LC1@l(r9)
-#endif
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp10	/* x+= 0.5;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	fsubs	fp9,fp1,fp10	/* x+= 0.5;  */
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp9,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__roundf)
-
-libm_alias_float (__round, round)
-
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S
deleted file mode 100644
index eab96dbba7..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* round function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __round __round_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c
new file mode 100644
index 0000000000..3f6f87b4e2
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __round __round_power5plus
+#include <sysdeps/powerpc/fpu/s_round.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S
deleted file mode 100644
index c2208c18fe..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* round function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __round __round_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_round.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c
new file mode 100644
index 0000000000..92fbadf789
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __round __round_ppc32
+#include <sysdeps/powerpc/fpu/s_round.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S
deleted file mode 100644
index ce4d89c669..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/* roundf function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef weak_alias
-#define weak_alias(name, alias)
-
-#define __roundf __roundf_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c
new file mode 100644
index 0000000000..b0cb5c5190
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __roundf __roundf_power5plus
+#include <sysdeps/powerpc/fpu/s_roundf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S
deleted file mode 100644
index 30f4e3f7cd..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/* roundf function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __roundf __roundf_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_roundf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c
new file mode 100644
index 0000000000..44023bbefd
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __roundf __roundf_ppc32
+#include <sysdeps/powerpc/fpu/s_roundf.c>
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S
deleted file mode 100644
index 327d970b02..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/* round function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-EALIGN (__round, 4, 0)
-	frin	fp1, fp1
-	blr
-	END (__round)
-
-libm_alias_double (__round, round)
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S
deleted file mode 100644
index 59a21708f5..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* roundf function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-EALIGN (__roundf, 4, 0)
-	frin	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__roundf)
-
-libm_alias_float (__round, round)
-
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index 8bb06e5cc0..722f974cfb 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -6,10 +6,16 @@ libm-sysdep_routines += s_ceil-power5+ \
 			s_floor-power5+ \
 			s_floor-ppc64 \
 			s_floorf-power5+ \
-			s_floorf-ppc64
+			s_floorf-ppc64 \
+			s_round-power5+ \
+			s_round-ppc64 \
+			s_roundf-power5+ \
+			s_roundf-ppc64
 
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
 CFLAGS-s_floor-power5+.c = -mcpu=power5+
 CFLAGS-s_floorf-power5+.c = -mcpu=power5+
+CFLAGS-s_round-power5+.c = -mcpu=power5+
+CFLAGS-s_roundf-power5+.c = -mcpu=power5+
 endif
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c
new file mode 100644
index 0000000000..3f6f87b4e2
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __round __round_power5plus
+#include <sysdeps/powerpc/fpu/s_round.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c
new file mode 100644
index 0000000000..cb122e6afc
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __round __round_ppc64
+#include <sysdeps/powerpc/fpu/s_round.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round.c
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c
new file mode 100644
index 0000000000..b0cb5c5190
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __roundf __roundf_power5plus
+#include <sysdeps/powerpc/fpu/s_roundf.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c
new file mode 100644
index 0000000000..3e1de69147
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __roundf __roundf_ppc64
+#include <sysdeps/powerpc/fpu/s_roundf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 8a73108e4c..11c39f4b35 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -15,8 +15,7 @@ sysdep_calls := s_copysign-power6 s_copysign-ppc64 \
 sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_llround-power6x \
 			s_llround-power5+ s_llround-ppc64 \
-			s_round-power5+ s_round-ppc64 \
-			s_roundf-power5+ s_roundf-ppc64 s_trunc-power5+ \
+			s_trunc-power5+ \
 			s_trunc-ppc64 s_truncf-power5+ s_truncf-ppc64 \
 			s_llrint-power6x s_llrint-ppc64 \
 			s_logb-power7 s_logbf-power7 \
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S
deleted file mode 100644
index 8c38759d3f..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* round function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __round __round_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S
deleted file mode 100644
index 5ea616d429..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* round function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __round __round_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_round.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S
deleted file mode 100644
index c29c31785e..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* roundf function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __roundf __roundf_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S
deleted file mode 100644
index ced4241b2b..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* roundf function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __roundf __roundf_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_roundf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_round.S b/sysdeps/powerpc/powerpc64/fpu/s_round.S
deleted file mode 100644
index 0b06a52d09..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_round.S
+++ /dev/null
@@ -1,80 +0,0 @@
-/* round function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	".toc","aw"
-.LC0:	/* 2**52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-.LC1:	/* 0.5 */
-	.tc FD_3fe00000_0[TC],0x3fe0000000000000
-	.section	".text"
-
-/* double [fp1] round (double x [fp1])
-   IEEE 1003.1 round function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "Round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "Round to Nearest" mode. Instead we set
-   "Round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.  */
-
-ENTRY (__round, 4)
-	CALL_MCOUNT 0
-	lfd	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding mode toward 0.  */
-	lfd	fp10,.LC1@toc(2)
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp10	/* x+= 0.5;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	fsub	fp9,fp1,fp10	/* x+= 0.5;  */
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp9,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__round)
-
-libm_alias_double (__round, round)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_roundf.S b/sysdeps/powerpc/powerpc64/fpu/s_roundf.S
deleted file mode 100644
index a9c32c5774..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_roundf.S
+++ /dev/null
@@ -1,82 +0,0 @@
-/* roundf  function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	".toc","aw"
-	.p2align 3
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-.LC1:	/* 0.5 */
-	.long 0x3f000000
-
-	.section	".text"
-
-/* float [fp1] roundf  (float x [fp1])
-   IEEE 1003.1 round function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "Round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "Round to Nearest" mode. Instead we set
-   "Round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.  */
-
-ENTRY (__roundf, 4)
-	CALL_MCOUNT 0
-	lfs	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding mode toward 0.  */
-	lfs	fp10,.LC1@toc(2)
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp10	/* x+= 0.5;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	fsubs	fp9,fp1,fp10	/* x+= 0.5;  */
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp9,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__roundf)
-
-libm_alias_float (__round, round)
-
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S
deleted file mode 100644
index 45d010a919..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* round function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__round, 4)
-	CALL_MCOUNT 0
-	frin	fp1, fp1
-	blr
-	END (__round)
-
-libm_alias_double (__round, round)
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S
deleted file mode 100644
index 69fad1069f..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* roundf function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__roundf, 4)
-	CALL_MCOUNT 0
-	frin	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__roundf)
-
-libm_alias_float (__round, round)
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 07/28] powerpc: trunc/truncf refactor
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 06/28] powerpc: round/roundf refactor Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-05-09 20:06   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 08/28] powerpc: generic nearbyint/nearbyintf Adhemerval Zanella
                   ` (20 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc trunc{f} implementations on
the generic sysdeps/powerpc/fpu/s_trunc{f}.  The generic implementation
uses either the compiler builts for ISA 2.03+ (which generates the
frim instruction) or a generic implementation which uses FP only
operations.

The IFUNC organization for powerpc64 is also change to be enabled only
for powerpc64 and not for powerpc64le.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/trunc_to_integer.h (set_truncing_mode): Add
	 TRUNC handling.
	* sysdeps/powerpc/fpu/s_trunc.c: New file.
	* sysdeps/powerpc/fpu/s_truncf.c: New file.
	* sysdeps/powerpc/powerpc32/fpu/s_trunc.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_truncf.S: Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-power5+.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-ppc32.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-power5+.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-ppc32.S:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-power5+.c: New
	file.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_trunc-ppc32.c:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-power5+.c:
	Likewise.
	* sysdep/powerpc/powepc32/power4/fpu/multiarch/s_truncf-ppc32.c:
	Likewise.
	* sysdep/powerpc/powerpc32/power5+/fpu/s_trunc.S: Remove file.
	* sysdep/powerpc/powerpc32/power5+/fpu/s_truncf.S: Likewise.
	* sysdep/powerpc/powerpc64/be/fpu/multiarch/Makefile
	(libm-sysdep_routines): Add s_trunc-power5+, s_trunc-ppc64,
	s_truncf-power5+, and s_truncf-ppc64.
	(CFLAGS-s_trunc-power5+.c, CFLAGS-s_truncf-power5+.c): New rule.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_trunc-power5+.c: New
	file.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_trunc-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc.c: ... here.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_truncf-power5+.c: New
	file.
	* sysdep/powerpc/powercp64/be/fpu/multiarch/s_truncf-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove s_trunc-power5+, s_trunc-ppc64,
	s_truncf-power5+, and s_truncf-ppc64.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S: Remove
	file.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S: Likewise.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S:
	Likewise.
	* sysdep/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_trunc.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Likewise.
	* sysdep/powerpc/powerpc64/power5+/fpu/s_trunc.S: Likewise.
	* sysdep/powerpc/powerpc64/power5+/fpu/s_truncf.S: Likewise.
---
 sysdeps/powerpc/fpu/round_to_integer.h        |  1 +
 sysdeps/powerpc/fpu/s_trunc.c                 | 35 ++++++++
 sysdeps/powerpc/fpu/s_truncf.c                | 35 ++++++++
 sysdeps/powerpc/powerpc32/fpu/s_trunc.S       | 83 -------------------
 sysdeps/powerpc/powerpc32/fpu/s_truncf.S      | 83 -------------------
 .../power4/fpu/multiarch/s_trunc-power5+.S    | 33 --------
 .../power4/fpu/multiarch/s_trunc-power5+.c    |  3 +
 .../power4/fpu/multiarch/s_trunc-ppc32.S      | 31 -------
 .../power4/fpu/multiarch/s_trunc-ppc32.c      |  3 +
 .../power4/fpu/multiarch/s_truncf-power5+.S   | 26 ------
 .../power4/fpu/multiarch/s_truncf-power5+.c   |  3 +
 .../power4/fpu/multiarch/s_truncf-ppc32.S     | 27 ------
 .../power4/fpu/multiarch/s_truncf-ppc32.c     |  3 +
 .../powerpc/powerpc32/power5+/fpu/s_trunc.S   | 29 -------
 .../powerpc/powerpc32/power5+/fpu/s_truncf.S  | 30 -------
 .../powerpc64/be/fpu/multiarch/Makefile       |  8 +-
 .../powerpc64/be/fpu/multiarch/s_roundf.c     |  2 -
 .../be/fpu/multiarch/s_trunc-power5+.c        |  3 +
 .../be/fpu/multiarch/s_trunc-ppc64.c          |  3 +
 .../{ => be}/fpu/multiarch/s_trunc.c          |  0
 .../be/fpu/multiarch/s_truncf-power5+.c       |  3 +
 .../be/fpu/multiarch/s_truncf-ppc64.c         |  3 +
 .../{ => be}/fpu/multiarch/s_truncf.c         |  2 -
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  2 -
 .../powerpc64/fpu/multiarch/s_trunc-power5+.S | 30 -------
 .../powerpc64/fpu/multiarch/s_trunc-ppc64.S   | 30 -------
 .../fpu/multiarch/s_truncf-power5+.S          | 24 ------
 .../powerpc64/fpu/multiarch/s_truncf-ppc64.S  | 24 ------
 sysdeps/powerpc/powerpc64/fpu/s_trunc.S       | 72 ----------------
 sysdeps/powerpc/powerpc64/fpu/s_truncf.S      | 74 -----------------
 .../powerpc/powerpc64/power5+/fpu/s_trunc.S   | 30 -------
 .../powerpc/powerpc64/power5+/fpu/s_truncf.S  | 31 -------
 32 files changed, 102 insertions(+), 664 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/s_trunc.c
 create mode 100644 sysdeps/powerpc/fpu/s_truncf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_truncf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_trunc.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_truncf.c (95%)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_truncf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S

diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
index 3fa2b77b6d..ba2d355fb0 100644
--- a/sysdeps/powerpc/fpu/round_to_integer.h
+++ b/sysdeps/powerpc/fpu/round_to_integer.h
@@ -38,6 +38,7 @@ set_fenv_mode (enum round_mode mode)
   {
   case CEIL:  rmode = FE_UPWARD; break;
   case FLOOR: rmode = FE_DOWNWARD; break;
+  case TRUNC:
   case ROUND: rmode = FE_TOWARDZERO; break;
   default:    rmode = FE_TONEAREST; break;
   }
diff --git a/sysdeps/powerpc/fpu/s_trunc.c b/sysdeps/powerpc/fpu/s_trunc.c
new file mode 100644
index 0000000000..83caf6b9cc
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_trunc.c
@@ -0,0 +1,35 @@
+/* Largest integral value not greater than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-double.h>
+#include <round_to_integer.h>
+
+double
+__trunc (double x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_trunc (x);
+#else
+  return round_to_integer_double (TRUNC, x);
+#endif
+}
+#ifndef __trunc
+libm_alias_double (__trunc, trunc)
+#endif
diff --git a/sysdeps/powerpc/fpu/s_truncf.c b/sysdeps/powerpc/fpu/s_truncf.c
new file mode 100644
index 0000000000..c9f091cf2a
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_truncf.c
@@ -0,0 +1,35 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-float.h>
+#include <round_to_integer.h>
+
+float
+__truncf (float x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_truncf (x);
+#else
+  return round_to_integer_float (TRUNC, x);
+#endif
+}
+#ifndef __truncf
+libm_alias_float (__trunc, trunc)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_trunc.S b/sysdeps/powerpc/powerpc32/fpu/s_trunc.S
deleted file mode 100644
index 31daff161f..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_trunc.S
+++ /dev/null
@@ -1,83 +0,0 @@
-/* trunc function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**52 */
-	.long 0x59800000
-
-/* double [fp1] trunc (double x [fp1])
-   IEEE 1003.1 trunc function.  IEEE specifies "trunc to the integer
-   value, in floating format, nearest to but no larger in magnitude
-   then the argument."
-   We set "round toward Zero" mode and trunc by adding +-2**52 then
-   subtracting +-2**52.  */
-
-	.section	".text"
-ENTRY (__trunc)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding toward 0 mode.  */
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__trunc)
-
-libm_alias_double (__trunc, trunc)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_truncf.S b/sysdeps/powerpc/powerpc32/fpu/s_truncf.S
deleted file mode 100644
index 630300c5dc..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_truncf.S
+++ /dev/null
@@ -1,83 +0,0 @@
-/* truncf function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-
-/* float [fp1] truncf (float x [fp1])
-   IEEE 1003.1 trunc function.  IEEE specifies "trunc to the integer
-   value, in floating format, nearest to but no larger in magnitude
-   then the argument."
-   We set "round toward Zero" mode and trunc by adding +-2**23 then
-   subtracting +-2**23.  */
-
-	.section	".text"
-ENTRY (__truncf)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding toward 0 mode.  */
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__truncf)
-
-libm_alias_float (__trunc, trunc)
-
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S
deleted file mode 100644
index 3ed99c3f7e..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* trunc function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __trunc __trunc_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c
new file mode 100644
index 0000000000..47abda6810
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __trunc __trunc_power5plus
+#include <sysdeps/powerpc/fpu/s_trunc.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S
deleted file mode 100644
index 67b87c5db1..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* trunc function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __trunc __trunc_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_trunc.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c
new file mode 100644
index 0000000000..5b9164295f
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __trunc __trunc_ppc32
+#include <sysdeps/powerpc/fpu/s_trunc.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S
deleted file mode 100644
index a18af562e6..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/* truncf function.  PowerPC32/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef weak_alias
-#define weak_alias(name, alias)
-
-#define __truncf __truncf_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c
new file mode 100644
index 0000000000..b8e75d4e28
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __truncf __truncf_power5plus
+#include <sysdeps/powerpc/fpu/s_truncf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S
deleted file mode 100644
index a7bf3943f2..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/* truncf function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __truncf __truncf_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_truncf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c
new file mode 100644
index 0000000000..f20c82553a
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf-ppc32.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __truncf __truncf_ppc32
+#include <sysdeps/powerpc/fpu/s_truncf.c>
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S
deleted file mode 100644
index 37a24104e7..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_trunc.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/* trunc function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-EALIGN (__trunc, 4, 0)
-	friz	fp1, fp1
-	blr
-	END (__trunc)
-
-libm_alias_double (__trunc, trunc)
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S
deleted file mode 100644
index f24c1f6cda..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* truncf function.  PowerPC32/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-EALIGN (__truncf, 4, 0)
-	friz	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__truncf)
-
-libm_alias_float (__trunc, trunc)
-
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index 722f974cfb..53e600f5f6 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -10,7 +10,11 @@ libm-sysdep_routines += s_ceil-power5+ \
 			s_round-power5+ \
 			s_round-ppc64 \
 			s_roundf-power5+ \
-			s_roundf-ppc64
+			s_roundf-ppc64 \
+			s_trunc-power5+ \
+			s_trunc-ppc64 \
+			s_truncf-power5+ \
+			s_truncf-ppc64
 
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
@@ -18,4 +22,6 @@ CFLAGS-s_floor-power5+.c = -mcpu=power5+
 CFLAGS-s_floorf-power5+.c = -mcpu=power5+
 CFLAGS-s_round-power5+.c = -mcpu=power5+
 CFLAGS-s_roundf-power5+.c = -mcpu=power5+
+CFLAGS-s_trunc-power5+.c = -mcpu=power5+
+CFLAGS-s_truncf-power5+.c = -mcpu=power5+
 endif
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c
index 640bca5a7a..db6a17c5b2 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c
@@ -18,8 +18,6 @@
 
 #define NO_MATH_REDIRECT
 #include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
 #include "init-arch.h"
 #include <libm-alias-float.h>
 
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c
new file mode 100644
index 0000000000..47abda6810
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __trunc __trunc_power5plus
+#include <sysdeps/powerpc/fpu/s_trunc.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c
new file mode 100644
index 0000000000..21c47308fc
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __trunc __trunc_ppc64
+#include <sysdeps/powerpc/fpu/s_trunc.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_trunc.c
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c
new file mode 100644
index 0000000000..b8e75d4e28
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-power5+.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __truncf __truncf_power5plus
+#include <sysdeps/powerpc/fpu/s_truncf.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c
new file mode 100644
index 0000000000..aa6c6c1f98
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf-ppc64.c
@@ -0,0 +1,3 @@
+#include <math.h>
+#define __truncf __truncf_ppc64
+#include <sysdeps/powerpc/fpu/s_truncf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c
similarity index 95%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c
index be124b2023..b6c8260b69 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_truncf.c
@@ -18,8 +18,6 @@
 
 #define NO_MATH_REDIRECT
 #include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
 #include "init-arch.h"
 #include <libm-alias-float.h>
 
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 11c39f4b35..7d469d79af 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -15,8 +15,6 @@ sysdep_calls := s_copysign-power6 s_copysign-ppc64 \
 sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_llround-power6x \
 			s_llround-power5+ s_llround-ppc64 \
-			s_trunc-power5+ \
-			s_trunc-ppc64 s_truncf-power5+ s_truncf-ppc64 \
 			s_llrint-power6x s_llrint-ppc64 \
 			s_logb-power7 s_logbf-power7 \
 			s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S
deleted file mode 100644
index 9ce3db48e4..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-power5+.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* trunc function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __trunc __trunc_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S
deleted file mode 100644
index ca9d831850..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc-ppc64.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* trunc function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __trunc __trunc_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_trunc.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S
deleted file mode 100644
index 4e651172af..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-power5+.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* truncf function.  PowerPC64/power5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __truncf __truncf_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S
deleted file mode 100644
index 5420eb26c7..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf-ppc64.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* truncf function.  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __truncf __truncf_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_truncf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_trunc.S b/sysdeps/powerpc/powerpc64/fpu/s_trunc.S
deleted file mode 100644
index 628960dd27..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_trunc.S
+++ /dev/null
@@ -1,72 +0,0 @@
-/* trunc function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	".toc","aw"
-.LC0:	/* 2**52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-	.section	".text"
-
-/* double [fp1] trunc (double x [fp1])
-   IEEE 1003.1 trunc function.  IEEE specifies "trunc to the integer
-   value, in floating format, nearest to but no larger in magnitude
-   then the argument."
-   We set "round toward Zero" mode and trunc by adding +-2**52 then
-   subtracting +-2**52.  */
-
-ENTRY (__trunc, 4)
-	CALL_MCOUNT 0
-	lfd	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding toward 0 mode.  */
-	ble-	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__trunc)
-
-libm_alias_double (__trunc, trunc)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_truncf.S b/sysdeps/powerpc/powerpc64/fpu/s_truncf.S
deleted file mode 100644
index 7b9294595a..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_truncf.S
+++ /dev/null
@@ -1,74 +0,0 @@
-/* truncf function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	".toc","aw"
-	.p2align 3
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-	.long 0x0
-	.section	".text"
-
-/* float [fp1] truncf (float x [fp1])
-   IEEE 1003.1 trunc function.  IEEE specifies "trunc to the integer
-   value, in floating format, nearest to but no larger in magnitude
-   then the argument."
-   We set "round toward Zero" mode and trunc by adding +-2**23 then
-   subtracting +-2**23.  */
-
-ENTRY (__truncf, 4)
-	CALL_MCOUNT 0
-	lfs	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	mffs	fp11		/* Save current FPU rounding mode and
-				   "inexact" state.  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl-	cr7,.L10
-	mtfsfi	7,1		/* Set rounding toward 0 mode.  */
-	ble-	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = 0.0; */
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L4:
-	bge-	cr6,.L9		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-				/* x = -0.0; */
-.L9:
-	mtfsf	0xff,fp11	/* Restore previous rounding mode and
-				   "inexact" state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__truncf)
-
-libm_alias_float (__trunc, trunc)
-
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S
deleted file mode 100644
index fbd0c318ef..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* trunc function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__trunc, 4)
-	CALL_MCOUNT 0
-	friz	fp1, fp1
-	blr
-	END (__trunc)
-
-libm_alias_double (__trunc, trunc)
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S
deleted file mode 100644
index 91612aa4e9..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* truncf function.  PowerPC64/power5+ version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.machine	"power5"
-ENTRY_TOCLESS (__truncf, 4)
-	CALL_MCOUNT 0
-	friz	fp1, fp1	/* The rounding instructions are double.  */
-	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
-	blr
-	END (__truncf)
-
-libm_alias_float (__trunc, trunc)
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 08/28] powerpc: generic nearbyint/nearbyintf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 07/28] powerpc: trunc/truncf refactor Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-05-27 20:42   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 09/28] powerpc: consolidate rint Adhemerval Zanella
                   ` (19 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc nearbyint{f} implementations
on the generic sysdeps/powerpc/fpu/s_nearbyint{f}.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/round_to_integer.h (set_fenv_mode): Add
	NEARBYINT handling.
	* sysdeps/powerpc/fpu/s_nearbyint.c: New file.
	* sysdeps/powerpc/fpu/s_nearbyintf.c: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Likewise.
---
 sysdeps/powerpc/fpu/round_to_integer.h       | 19 +++--
 sysdeps/powerpc/fpu/s_nearbyint.c            | 30 ++++++++
 sysdeps/powerpc/fpu/s_nearbyintf.c           | 30 ++++++++
 sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S  | 80 --------------------
 sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S | 79 -------------------
 sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S  | 68 -----------------
 sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S | 69 -----------------
 7 files changed, 73 insertions(+), 302 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/s_nearbyint.c
 create mode 100644 sysdeps/powerpc/fpu/s_nearbyintf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S

diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
index ba2d355fb0..5d4378063a 100644
--- a/sysdeps/powerpc/fpu/round_to_integer.h
+++ b/sysdeps/powerpc/fpu/round_to_integer.h
@@ -33,16 +33,23 @@ enum round_mode
 static inline void
 set_fenv_mode (enum round_mode mode)
 {
-  int rmode;
   switch (mode)
   {
-  case CEIL:  rmode = FE_UPWARD; break;
-  case FLOOR: rmode = FE_DOWNWARD; break;
+  case CEIL:
+    __fesetround_inline_nocheck (FE_UPWARD);
+    break;
+  case FLOOR:
+    __fesetround_inline_nocheck (FE_DOWNWARD);
+    break;
   case TRUNC:
-  case ROUND: rmode = FE_TOWARDZERO; break;
-  default:    rmode = FE_TONEAREST; break;
+  case ROUND:
+    __fesetround_inline_nocheck (FE_TOWARDZERO);
+    break;
+  case NEARBYINT:
+    /*  Disable FE_INEXACT exception  */
+    reset_fpscr_bit (FPSCR_XE);
+    break;
   }
-  __fesetround_inline_nocheck (rmode);
 }
 
 static inline float
diff --git a/sysdeps/powerpc/fpu/s_nearbyint.c b/sysdeps/powerpc/fpu/s_nearbyint.c
new file mode 100644
index 0000000000..48bcd86f04
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_nearbyint.c
@@ -0,0 +1,30 @@
+/* Largest integral value not greater than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-double.h>
+#include <round_to_integer.h>
+
+double
+__nearbyint (double x)
+{
+  return round_to_integer_double (NEARBYINT, x);
+}
+libm_alias_double (__nearbyint, nearbyint)
diff --git a/sysdeps/powerpc/fpu/s_nearbyintf.c b/sysdeps/powerpc/fpu/s_nearbyintf.c
new file mode 100644
index 0000000000..db8a3cdac7
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_nearbyintf.c
@@ -0,0 +1,30 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-float.h>
+#include <round_to_integer.h>
+
+float
+__nearbyintf (float x)
+{
+  return round_to_integer_float (NEARBYINT, x);
+}
+libm_alias_float (__nearbyint, nearbyint)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S b/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S
deleted file mode 100644
index 4ed5d702f1..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Round to int floating-point values.  PowerPC32 version.
-   Copyright (C) 2011-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-
-/* double [fp1] nearbyint(double [fp1] x) */
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**52 */
-	.long 0x59800000	/* TWO52: 2**52 */
-
-	.section	".text"
-ENTRY (__nearbyint)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	bcl	20,31,1f
-1:	mflr	r9
-	addis	r9,r9,.LC0-1b@ha
-	lfs	fp13,.LC0-1b@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsub    fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52 */
-	bge	cr7,.L10
-	fcmpu	cr7,fp1,fp12	/* if (x > 0.0 */
-	ble	cr7,L(lessthanzero)
-	mffs	fp11
-	mtfsb0	4*cr7+lt	/* Disable FE_INEXACT exception */
-	fadd	fp1,fp1,fp13	/* x += TWO52 */
-	fsub	fp1,fp1,fp13	/* x -= TWO52 */
-	fabs	fp1,fp1		/* if (x == 0.0 */
-	mtfsf	0xff,fp11	/* Restore FE_INEXACT state.  */
-	blr
-L(lessthanzero):
-	bgelr	cr7
-	mffs	fp11
-	mtfsb0	4*cr7+lt	/* Disable FE_INEXACT exception */
-	fsub	fp1,fp1,fp13	/* x -= TWO52 */
-	fadd	fp1,fp1,fp13	/* x += TWO52 */
-	fnabs	fp1,fp1		/* if (x == 0.0) */
-	mtfsf	0xff,fp11	/* Restore FE_INEXACT state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-END (__nearbyint)
-
-libm_alias_double (__nearbyint, nearbyint)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S b/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
deleted file mode 100644
index b1895f9d10..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Round to int floating-point values.  PowerPC32 version.
-   Copyright (C) 2011-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-
-/* float [fp1] nearbyintf(float [fp1] x) */
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:
-	.long 0x4B000000	/* TWO23: 2**23 */
-
-	.section	".text"
-ENTRY (__nearbyintf)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	bcl	20,31,1f
-1:	mflr	r9
-	addis	r9,r9,.LC0-1b@ha
-	lfs	fp13,.LC0-1b@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsub    fp12,fp13,fp13		/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13		/* if (fabs(x) > TWO23 */
-	bge	cr7,.L10
-	fcmpu	cr7,fp1,fp12		/* if (x > 0.0 */
-	ble	cr7,L(lessthanzero)
-	mffs	fp11
-	mtfsb0	4*cr7+lt		/* Disable FE_INEXACT exception */
-	fadds	fp1,fp1,fp13		/* x += TWO23 */
-	fsubs	fp1,fp1,fp13		/* x -= TWO23 */
-	fabs	fp1,fp1			/* if (x == 0.0) */
-	mtfsf	0xff,fp11		/* Restore FE_INEXACT state.  */
-	blr
-L(lessthanzero):
-	bgelr	cr7
-	mffs	fp11
-	mtfsb0	4*cr7+lt		/* Disable FE_INEXACT exception */
-	fsubs	fp1,fp1,fp13		/* x -= TWO23 */
-	fadds	fp1,fp1,fp13		/* x += TWO23 */
-	fnabs	fp1,fp1			/* if (x == 0.0) */
-	mtfsf	0xff,fp11		/* Restore FE_INEXACT state.  */
-	blr
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-END (__nearbyintf)
-
-libm_alias_float (__nearbyint, nearbyint)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S b/sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S
deleted file mode 100644
index 4065af8fe3..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Round to int floating-point values.  PowerPC64 version.
-   Copyright (C) 2011-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-
-/* double [fp1] nearbyint(double [fp1] x) */
-
-	.section	".toc","aw"
-.LC0:	/* 2**52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-	.section	".text"
-
-ENTRY (__nearbyint, 4)
-	CALL_MCOUNT 0
-	fabs	fp0,fp1
-	lfd	fp13,.LC0@toc(2)
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	bge	cr7,.L10
-	fsub	fp12,fp13,fp13	/* generate 0.0 */
-	fcmpu	cr7,fp1,fp12	/* if (x > 0.0) */
-	ble	cr7, L(lessthanzero)
-	mffs	fp11
-	mtfsb0	4*cr7+lt	/* Disable FE_INEXACT exception */
-	fadd	fp1,fp1,fp13	/* x+= TWO52 */
-	fsub	fp1,fp1,fp13	/* x-= TWO52 */
-	fabs	fp1,fp1		/* if (x == 0.0) */
-	mtfsf	0xff,fp11	/* Restore FE_INEXACT state.  */
-	blr			/* x = 0.0; */
-L(lessthanzero):
-	bgelr	cr7		/* if (x < 0.0) */
-	mffs	fp11
-	mtfsb0	4*cr7+lt
-	fsub	fp1,fp1,fp13	/* x -= TWO52 */
-	fadd	fp1,fp1,fp13	/* x += TWO52 */
-	fnabs	fp1,fp1		/* if (x == 0.0) */
-	mtfsf	0xff,fp11	/* Restore FE_INEXACT state.  */
-	blr			/* x = -0.0; */
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-END (__nearbyint)
-
-libm_alias_double (__nearbyint, nearbyint)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S b/sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S
deleted file mode 100644
index 69949028a3..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Round to int floating-point values.  PowerPC64 version.
-   Copyright (C) 2011-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-
-/* float [fp1] nearbyintf(float [fp1]) */
-
-	.section	".toc","aw"
-	.p2align 3
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-	.long 0x0
-	.section	".text"
-
-ENTRY (__nearbyintf, 4)
-	CALL_MCOUNT 0
-	fabs	fp0,fp1
-	lfs	fp13,.LC0@toc(2)
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	bge	cr7,.L10
-	fsubs	fp12,fp13,fp13	/* generate 0.0 */
-	fcmpu	cr7,fp1,fp12	/* if (x > 0.0)  */
-	ble	cr7, L(lessthanzero)
-	mffs	fp11
-	mtfsb0	4*cr7+lt	/* Disable FE_INEXACT exception */
-	fadds	fp1,fp1,fp13	/* x += TWO23 */
-	fsubs	fp1,fp1,fp13	/* x -= TWO23 */
-	fabs	fp1,fp1		/* if (x == 0.0) */
-	mtfsf	0xff,fp11	/* Restore FE_INEXACT state.  */
-	blr			/* x = 0.0; */
-L(lessthanzero):
-	bgelr	cr7		/* if (x < 0.0) */
-	mffs	fp11
-	mtfsb0	4*cr7+lt	/* Disable FE_INEXACT exception */
-	fsubs	fp1,fp1,fp13	/* x -= TWO23 */
-	fadds	fp1,fp1,fp13	/* x += TWO23 */
-	fnabs	fp1,fp1		/* if (x == 0.0) */
-	mtfsf	0xff,fp11	/* Restore FE_INEXACT state.  */
-	blr			/* x = -0.0; */
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-END (__nearbyintf)
-
-libm_alias_float (__nearbyint, nearbyint)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 09/28] powerpc: consolidate rint
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (7 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 08/28] powerpc: generic nearbyint/nearbyintf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-05-30 14:36   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 10/28] powerpc: copysign cleanup Adhemerval Zanella
                   ` (18 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc rint{f} implementations on
the generic sysdeps/powerpc/fpu/s_rint{f}.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/round_to_integer.h (set_fenv_mode,
	round_to_integer_float): Add RINT handling.
	(reset_fenv_mode): New symbol.
	* sysdeps/powerpc/fpu/s_rint.c (__rint): Use generic implementation.
	* sysdeps/powerpc/fpu/s_rintf.c (__rintf): Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_rint.S: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_rintf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_rint.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_rintf.S: Likewise.
---
 sysdeps/powerpc/fpu/round_to_integer.h  | 35 ++++++++++---
 sysdeps/powerpc/fpu/s_rint.c            | 19 +------
 sysdeps/powerpc/fpu/s_rintf.c           | 19 +------
 sysdeps/powerpc/powerpc32/fpu/s_rint.S  | 69 -------------------------
 sysdeps/powerpc/powerpc32/fpu/s_rintf.S | 66 -----------------------
 sysdeps/powerpc/powerpc64/fpu/s_rint.S  | 58 ---------------------
 sysdeps/powerpc/powerpc64/fpu/s_rintf.S | 57 --------------------
 7 files changed, 31 insertions(+), 292 deletions(-)
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_rint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_rintf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_rint.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_rintf.S

diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
index 5d4378063a..c759483230 100644
--- a/sysdeps/powerpc/fpu/round_to_integer.h
+++ b/sysdeps/powerpc/fpu/round_to_integer.h
@@ -28,11 +28,17 @@ enum round_mode
   ROUND,
   TRUNC,
   NEARBYINT,
+  RINT
 };
 
-static inline void
+static inline fenv_t
 set_fenv_mode (enum round_mode mode)
 {
+  fenv_t fe = 0;
+  if (mode != RINT)
+    /* Save current FPU rounding mode and inexact state.  */
+    fe = fegetenv_register ();
+
   switch (mode)
   {
   case CEIL:
@@ -49,6 +55,22 @@ set_fenv_mode (enum round_mode mode)
     /*  Disable FE_INEXACT exception  */
     reset_fpscr_bit (FPSCR_XE);
     break;
+  case RINT:
+    break;
+  }
+  return fe;
+}
+
+static inline void
+reset_fenv_mode (fenv_t fe, enum round_mode mode)
+{
+  switch (mode)
+  {
+  default:
+    __builtin_mtfsf (0xff, fe);
+    break;
+  case RINT:
+    break;
   }
 }
 
@@ -64,9 +86,7 @@ round_to_integer_float (enum round_mode mode, float x)
 
   float r = x;
 
-  /* Save current FPU rounding mode and inexact state.  */
-  fenv_t fe = fegetenv_register ();
-  set_fenv_mode (mode);
+  fenv_t fe = set_fenv_mode (mode);
   if (x > 0.0)
     {
       /* IEEE 1003.1 round function.  IEEE specifies "round to the nearest
@@ -91,7 +111,7 @@ round_to_integer_float (enum round_mode mode, float x)
       r += 0x1p+23;
       r = -fabs (r);
     }
-  __builtin_mtfsf (0xff, fe);
+  reset_fenv_mode (fe, mode);
 
   return r;
 }
@@ -109,8 +129,7 @@ round_to_integer_double (enum round_mode mode, double x)
   double r = x;
 
   /* Save current FPU rounding mode and inexact state.  */
-  fenv_t fe = fegetenv_register ();
-  set_fenv_mode (mode);
+  fenv_t fe = set_fenv_mode (mode);
   if (x > 0.0)
     {
       if (mode == ROUND)
@@ -127,7 +146,7 @@ round_to_integer_double (enum round_mode mode, double x)
       r += 0x1p+52;
       r = -fabs (r);
     }
-  __builtin_mtfsf (0xff, fe);
+  reset_fenv_mode (fe, mode);
 
   return r;
 }
diff --git a/sysdeps/powerpc/fpu/s_rint.c b/sysdeps/powerpc/fpu/s_rint.c
index 8bf43e3efe..062d6b125b 100644
--- a/sysdeps/powerpc/fpu/s_rint.c
+++ b/sysdeps/powerpc/fpu/s_rint.c
@@ -19,26 +19,11 @@
 #define NO_MATH_REDIRECT
 #include <math.h>
 #include <libm-alias-double.h>
+#include <round_to_integer.h>
 
 double
 __rint (double x)
 {
-  static const float TWO52 = 4503599627370496.0;
-
-  if (fabs (x) < TWO52)
-    {
-      if (x > 0.0)
-	{
-	  x += TWO52;
-	  x -= TWO52;
-	}
-      else if (x < 0.0)
-	{
-	  x = TWO52 - x;
-	  x = -(x - TWO52);
-	}
-    }
-
-  return x;
+  return round_to_integer_double (RINT, x);
 }
 libm_alias_double (__rint, rint)
diff --git a/sysdeps/powerpc/fpu/s_rintf.c b/sysdeps/powerpc/fpu/s_rintf.c
index 03aaec2c85..c29e7a22b4 100644
--- a/sysdeps/powerpc/fpu/s_rintf.c
+++ b/sysdeps/powerpc/fpu/s_rintf.c
@@ -19,26 +19,11 @@
 #define NO_MATH_REDIRECT
 #include <math.h>
 #include <libm-alias-float.h>
+#include <round_to_integer.h>
 
 float
 __rintf (float x)
 {
-  static const float TWO23 = 8388608.0;
-
-  if (fabsf (x) < TWO23)
-    {
-      if (x > 0.0)
-	{
-	  x += TWO23;
-	  x -= TWO23;
-	}
-      else if (x < 0.0)
-	{
-	  x = TWO23 - x;
-	  x = -(x - TWO23);
-	}
-    }
-
-  return x;
+  return round_to_integer_float (RINT, x);
 }
 libm_alias_float (__rint, rint)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_rint.S b/sysdeps/powerpc/powerpc32/fpu/s_rint.S
deleted file mode 100644
index 0b50b6f053..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_rint.S
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Round to int floating-point values.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**52 */
-	.long 0x59800000
-
-	.section	".text"
-ENTRY (__rint)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl	cr7,.L10
-	bng	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = 0.0; */
-.L4:
-	bnllr	cr6		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = -0.0; */
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__rint)
-
-libm_alias_double (__rint, rint)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_rintf.S b/sysdeps/powerpc/powerpc32/fpu/s_rintf.S
deleted file mode 100644
index f22ad8b2b3..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_rintf.S
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Round float to int floating-point values.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-
-	.section	".text"
-ENTRY (__rintf)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfs	fp13,.LC0-got_label@l(r9)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp13,.LC0@l(r9)
-#endif
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl	cr7,.L10
-	bng	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = 0.0; */
-.L4:
-	bnllr	cr6		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = -0.0; */
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__rintf)
-
-libm_alias_float (__rint, rint)
-
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_rint.S b/sysdeps/powerpc/powerpc64/fpu/s_rint.S
deleted file mode 100644
index 5616f4d908..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_rint.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Round to int floating-point values.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	".toc","aw"
-.LC0:	/* 2**52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-	.section	".text"
-
-ENTRY (__rint, 4)
-	CALL_MCOUNT 0
-	lfd	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsub	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO52)  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl	cr7,.L10
-	bng	cr6,.L4
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = 0.0; */
-.L4:
-	bnllr	cr6		/* if (x < 0.0)  */
-	fsub	fp1,fp1,fp13	/* x-= TWO52;  */
-	fadd	fp1,fp1,fp13	/* x+= TWO52;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = -0.0; */
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadd	fp1,fp1,fp1
-	blr
-	END (__rint)
-
-libm_alias_double (__rint, rint)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_rintf.S b/sysdeps/powerpc/powerpc64/fpu/s_rintf.S
deleted file mode 100644
index 4511467584..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_rintf.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Round float to int floating-point values.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	".toc","aw"
-	.p2align 3
-.LC0:	/* 2**23 */
-	.long 0x4b000000
-	.long 0x0
-	.section	".text"
-
-ENTRY (__rintf, 4)
-	CALL_MCOUNT 0
-	lfs	fp13,.LC0@toc(2)
-	fabs	fp0,fp1
-	fsubs	fp12,fp13,fp13	/* generate 0.0  */
-	fcmpu	cr7,fp0,fp13	/* if (fabs(x) > TWO23)  */
-	fcmpu	cr6,fp1,fp12	/* if (x > 0.0)  */
-	bnl	cr7,.L10
-	bng	cr6,.L4
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = 0.0; */
-.L4:
-	bnllr	cr6		/* if (x < 0.0)  */
-	fsubs	fp1,fp1,fp13	/* x-= TWO23;  */
-	fadds	fp1,fp1,fp13	/* x+= TWO23;  */
-	fnabs	fp1,fp1		/* if (x == 0.0)  */
-	blr			/* x = -0.0; */
-.L10:
-	/* Ensure sNaN input is converted to qNaN.  */
-	fcmpu	cr7,fp1,fp1
-	beqlr	cr7
-	fadds	fp1,fp1,fp1
-	blr
-	END (__rintf)
-
-libm_alias_float (__rint, rint)
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 10/28] powerpc: copysign cleanup
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (8 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 09/28] powerpc: consolidate rint Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-05-31 14:14   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 11/28] benchtests: Add isnan/isinf/isfinite benchmark Adhemerval Zanella
                   ` (17 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

GCC always expand copysign{f} for all possible cpus, so calling the libm
is only done if user explicitly states to disable the builtin (which is
usually done not for performance reason).  So to provide ifunc variant
for copysign only adds complexity for powerpc and powerpc64 and it not
required for powerpc64le.

This patch removes both powerpc32 and powerpc64 ifunc variants and
consolidates the powerpc implementation on
sysdeps/powerpc/fpu/s_copysign{f}.c using compiler builtins.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/s_copysign.c: New file.
	* sysdeps/powerpc/fpu/s_copysignf.c: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_copysign.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_copysignf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
	(sysdep_routines, libm-sysdep_routines): Remove s_copysign-power6 and
	s_copysign-ppc32.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-power6.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile (sysdeps_calls):
	Remove s_copysign-power6 s_copysign-ppc64.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-power6.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-ppc64.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_copysignf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/fpu/s_copysignf.S: Likewise.
---
 sysdeps/powerpc/fpu/s_copysign.c              | 32 +++++++++++
 sysdeps/powerpc/fpu/s_copysignf.c             | 28 ++++++++++
 sysdeps/powerpc/powerpc32/fpu/s_copysign.S    | 53 -------------------
 sysdeps/powerpc/powerpc32/fpu/s_copysignf.S   |  1 -
 .../powerpc32/power4/fpu/multiarch/Makefile   |  6 +--
 .../power4/fpu/multiarch/s_copysign-power6.S  | 33 ------------
 .../power4/fpu/multiarch/s_copysign-ppc32.S   | 34 ------------
 .../power4/fpu/multiarch/s_copysign.c         | 45 ----------------
 .../power4/fpu/multiarch/s_copysignf.c        | 34 ------------
 .../powerpc/powerpc32/power6/fpu/s_copysign.S | 49 -----------------
 .../powerpc32/power6/fpu/s_copysignf.S        |  1 -
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  3 +-
 .../fpu/multiarch/s_copysign-power6.S         | 32 -----------
 .../fpu/multiarch/s_copysign-ppc64.S          | 34 ------------
 .../powerpc64/fpu/multiarch/s_copysign.c      | 45 ----------------
 .../powerpc64/fpu/multiarch/s_copysignf.c     | 34 ------------
 sysdeps/powerpc/powerpc64/fpu/s_copysign.S    | 53 -------------------
 sysdeps/powerpc/powerpc64/fpu/s_copysignf.S   |  1 -
 .../powerpc/powerpc64/power6/fpu/s_copysign.S | 49 -----------------
 .../powerpc64/power6/fpu/s_copysignf.S        |  1 -
 20 files changed, 64 insertions(+), 504 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/s_copysign.c
 create mode 100644 sysdeps/powerpc/fpu/s_copysignf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_copysignf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_copysignf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/fpu/s_copysignf.S

diff --git a/sysdeps/powerpc/fpu/s_copysign.c b/sysdeps/powerpc/fpu/s_copysign.c
new file mode 100644
index 0000000000..364242e5d9
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_copysign.c
@@ -0,0 +1,32 @@
+/* Copy sign of a number.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <math_ldbl_opt.h>
+#include <libm-alias-double.h>
+
+double
+__copysign (double x, double y)
+{
+  return __builtin_copysign (x, y);
+}
+libm_alias_double (__copysign, copysign)
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+compat_symbol (libc, __copysign, copysignl, GLIBC_2_0);
+#endif
diff --git a/sysdeps/powerpc/fpu/s_copysignf.c b/sysdeps/powerpc/fpu/s_copysignf.c
new file mode 100644
index 0000000000..d423bfa793
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_copysignf.c
@@ -0,0 +1,28 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-float.h>
+
+float
+__copysignf (float x, float y)
+{
+  return __builtin_copysignf (x, y);
+}
+libm_alias_float (__copysign, copysign)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_copysign.S b/sysdeps/powerpc/powerpc32/fpu/s_copysign.S
deleted file mode 100644
index fa9e5a2a1a..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_copysign.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copy a sign bit between floating-point values.
-   Copyright (C) 1997-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-ENTRY(__copysign)
-/* double [f1] copysign (double [f1] x, double [f2] y);
-   copysign(x,y) returns a value with the magnitude of x and
-   with the sign bit of y.  */
-	stwu	r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	stfd	fp2,8(r1)
-	lwz	r3,8+HIWORD(r1)
-	cmpwi   r3,0
-	addi    r1,r1,16
-	cfi_adjust_cfa_offset (-16)
-	blt     L(0)
-	fabs    fp1,fp1
-	blr
-L(0):	fnabs   fp1,fp1
-	blr
-	END (__copysign)
-
-libm_alias_double (__copysign, copysign)
-
-/* It turns out that it's safe to use this code even for single-precision.  */
-strong_alias(__copysign,__copysignf)
-libm_alias_float (__copysign, copysign)
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __copysign, copysignl, GLIBC_2_0)
-#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_copysignf.S b/sysdeps/powerpc/powerpc32/fpu/s_copysignf.S
deleted file mode 100644
index e05438ae7d..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_copysignf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __copysignf is in s_copysign.S  */
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index cf38e347f2..7008e775b7 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -2,8 +2,8 @@ ifeq ($(subdir),math)
 sysdep_routines += s_isnan-power7 s_isnan-power6 s_isnan-power5 s_isnan-ppc32 \
 		   s_isnanf-power6 s_isnanf-power5 s_isinf-power7 \
 		   s_isinf-ppc32 s_isinff-ppc32 s_finite-power7 \
-		   s_finite-ppc32 s_finitef-ppc32 s_copysign-power6 \
-		   s_copysign-ppc32 s_modf-power5+ s_modf-ppc32 \
+		   s_finite-ppc32 s_finitef-ppc32 \
+		   s_modf-power5+ s_modf-ppc32 \
 		   s_modff-power5+ s_modff-ppc32
 
 libm-sysdep_routines += s_llrintf-power6 s_llrintf-ppc32 s_llrint-power6 \
@@ -18,7 +18,7 @@ libm-sysdep_routines += s_llrintf-power6 s_llrintf-ppc32 s_llrint-power6 \
 			s_floorf-ppc32 s_round-power5+ s_round-ppc32 \
 			s_roundf-power5+ s_roundf-ppc32 s_trunc-power5+ \
 			s_trunc-ppc32 s_truncf-power5+ s_truncf-ppc32 \
-			s_copysign-power6 s_copysign-ppc32 s_lround-power6x \
+			s_lround-power6x \
 			s_lround-power5+ s_lround-ppc32 s_lrint-power6x \
 			s_lrint-ppc32 s_modf-power5+ s_modf-ppc32 \
 			s_modff-power5+ s_modff-ppc32 s_logbl-power7 \
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-power6.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-power6.S
deleted file mode 100644
index 24ab12e41e..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-power6.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* copysign().  PowerPC32/POWER6 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __copysign __copysign_power6
-
-#include <sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S
deleted file mode 100644
index 0c283c65b0..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/* copysign().  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a, b, c, d)
-
-#define __copysign __copysign_ppc32
-#undef hidden_def
-#define hidden_def(name)
-  strong_alias (__copysign_ppc32, __GI___copysign)
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_copysign.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c
deleted file mode 100644
index f9d1795732..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Multiple versions of copysign.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define NO_MATH_REDIRECT
-/* Redefine copysign so that the compiler won't complain about the type
-   mismatch with the IFUNC selector in strong_alias below.  */
-#undef __copysign
-#define __copysign __redirect_copysign
-#include <math.h>
-#include <math_ldbl_opt.h>
-#undef __copysign
-#include <shlib-compat.h>
-#include "init-arch.h"
-#include <libm-alias-double.h>
-
-extern __typeof (__redirect_copysign) __copysign_ppc32 attribute_hidden;
-extern __typeof (__redirect_copysign) __copysign_power6 attribute_hidden;
-
-extern __typeof (__redirect_copysign) __libm_copysign;
-libc_ifunc (__libm_copysign,
-	    (hwcap & PPC_FEATURE_ARCH_2_05)
-	    ? __copysign_power6
-            : __copysign_ppc32);
-
-strong_alias (__libm_copysign, __copysign)
-libm_alias_double (__copysign, copysign)
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __copysign, copysignl, GLIBC_2_0);
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c
deleted file mode 100644
index 12354d0872..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Multiple versions of copysignf.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define NO_MATH_REDIRECT
-#include <math.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-#include <libm-alias-float.h>
-
-/* It's safe to use double-precision implementation for single-precision.  */
-extern __typeof (__copysignf) __copysign_ppc32 attribute_hidden;
-extern __typeof (__copysignf) __copysign_power6 attribute_hidden;
-
-libc_ifunc (__copysignf,
-	    (hwcap & PPC_FEATURE_ARCH_2_05)
-	    ? __copysign_power6
-            : __copysign_ppc32);
-
-libm_alias_float (__copysign, copysign)
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S
deleted file mode 100644
index abf84ca191..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S
+++ /dev/null
@@ -1,49 +0,0 @@
-/* copysign().  PowerPC32/POWER6 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* double [f1] copysign (double [f1] x, double [f2] y);
-   copysign(x,y) returns a value with the magnitude of x and
-   with the sign bit of y.  */
-
-	.section    ".text"
-	.type	    __copysign, @function
-	.machine    power6
-EALIGN (__copysign, 4, 0)
-	CALL_MCOUNT
-	fcpsgn	fp1,fp2,fp1
-	blr
-END (__copysign)
-
-hidden_def (__copysign)
-libm_alias_double (__copysign, copysign)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__copysign, __copysignf)
-hidden_def (__copysignf)
-libm_alias_float (__copysign, copysign)
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, copysign, copysignl, GLIBC_2_0);
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S
deleted file mode 100644
index d4aa702d07..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_copysign.S.  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 7d469d79af..36d5e65ee1 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -2,8 +2,7 @@ ifeq ($(subdir),math)
 # These functions are built both for libc and libm because they're required
 # by printf.  While the libc objects have the prefix s_, the libm ones are
 # prefixed with  m_.
-sysdep_calls := s_copysign-power6 s_copysign-ppc64 \
-		s_finite-power8 s_finite-power7 s_finite-ppc64 \
+sysdep_calls := s_finite-power8 s_finite-power7 s_finite-ppc64 \
 		s_finitef-ppc64 \
 		s_isinf-power8 s_isinf-ppc64 \
 		s_isinff-ppc64 s_isinf-power7 \
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-power6.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-power6.S
deleted file mode 100644
index e901cea480..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-power6.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* copysign().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a, b, c, d)
-#undef hidden_def
-#define hidden_def(name)
-
-#define __copysign __copysign_power6
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_copysign.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-ppc64.S
deleted file mode 100644
index a4a783f3f6..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-ppc64.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/* copysign().  PowerPC64 default version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a, b, c, d)
-
-#define __copysign __copysign_ppc64
-#undef hidden_def
-#define hidden_def(name)				\
-  strong_alias (__copysign_ppc64, __GI___copysign)
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_copysign.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c
deleted file mode 100644
index 3d7f7f051d..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Multiple versions of copysign.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define NO_MATH_REDIRECT
-/* Redefine copysign so that the compiler won't complain about the type
-   mismatch with the IFUNC selector in strong_alias below.  */
-#undef __copysign
-#define __copysign __redirect_copysign
-#include <math.h>
-#include <math_ldbl_opt.h>
-#undef __copysign
-#include <shlib-compat.h>
-#include "init-arch.h"
-#include <libm-alias-double.h>
-
-extern __typeof (__redirect_copysign) __copysign_ppc64 attribute_hidden;
-extern __typeof (__redirect_copysign) __copysign_power6 attribute_hidden;
-
-extern __typeof (__redirect_copysign) __libm_copysign;
-libc_ifunc (__libm_copysign,
-	    (hwcap & PPC_FEATURE_ARCH_2_05)
-	    ? __copysign_power6
-            : __copysign_ppc64);
-
-strong_alias (__libm_copysign, __copysign)
-libm_alias_double (__copysign, copysign)
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __copysign, copysignl, GLIBC_2_0);
-#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c
deleted file mode 100644
index d20984b01a..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Multiple versions of copysignf.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define NO_MATH_REDIRECT
-#include <math.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-#include <libm-alias-float.h>
-
-/* It's safe to use double-precision implementation for single-precision. */
-extern __typeof (__copysignf) __copysign_ppc64 attribute_hidden;
-extern __typeof (__copysignf) __copysign_power6 attribute_hidden;
-
-libc_ifunc (__copysignf,
-	    (hwcap & PPC_FEATURE_ARCH_2_05)
-	    ? __copysign_power6
-            : __copysign_ppc64);
-
-libm_alias_float (__copysign, copysign)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_copysign.S b/sysdeps/powerpc/powerpc64/fpu/s_copysign.S
deleted file mode 100644
index bf6283361c..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_copysign.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copy a sign bit between floating-point values.  PowerPC64 version.
-   Copyright (C) 1997-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-ENTRY_TOCLESS (__copysign)
-	CALL_MCOUNT 0
-/* double [f1] copysign (double [f1] x, double [f2] y);
-   copysign(x,y) returns a value with the magnitude of x and
-   with the sign bit of y.  */
-	stfd	fp2,-8(r1)
-	nop
-	nop
-	nop
-	ld	r3,-8(r1)
-	cmpdi   r3,0
-	blt     L(0)
-	fabs    fp1,fp1
-	blr
-L(0):	fnabs   fp1,fp1
-	blr
-	END (__copysign)
-
-libm_alias_double (__copysign, copysign)
-
-/* It turns out that it's safe to use this code even for single-precision.  */
-strong_alias(__copysign,__copysignf)
-libm_alias_float (__copysign, copysign)
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __copysign, copysignl, GLIBC_2_0)
-#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_copysignf.S b/sysdeps/powerpc/powerpc64/fpu/s_copysignf.S
deleted file mode 100644
index e05438ae7d..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_copysignf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __copysignf is in s_copysign.S  */
diff --git a/sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S b/sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S
deleted file mode 100644
index feba531e5b..0000000000
--- a/sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S
+++ /dev/null
@@ -1,49 +0,0 @@
-/* copysign().  PowerPC64/POWER6 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* double [f1] copysign (double [f1] x, double [f2] y);
-   copysign(x,y) returns a value with the magnitude of x and
-   with the sign bit of y.  */
-
-	.section    ".text"
-	.type	    __copysign, @function
-	.machine    power6
-ENTRY_TOCLESS (__copysign, 4)
-	CALL_MCOUNT 0
-	fcpsgn	fp1,fp2,fp1
-	blr
-END (__copysign)
-
-hidden_def (__copysign)
-libm_alias_double (__copysign, copysign)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__copysign, __copysignf)
-hidden_def (__copysignf)
-libm_alias_float (__copysign, copysign)
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, copysign, copysignl, GLIBC_2_0);
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power6/fpu/s_copysignf.S b/sysdeps/powerpc/powerpc64/power6/fpu/s_copysignf.S
deleted file mode 100644
index d4aa702d07..0000000000
--- a/sysdeps/powerpc/powerpc64/power6/fpu/s_copysignf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_copysign.S.  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 11/28] benchtests: Add isnan/isinf/isfinite benchmark
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (9 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 10/28] powerpc: copysign cleanup Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-05 22:45   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 12/28] math: Use wordsize-64 version for isnan Adhemerval Zanella
                   ` (16 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* benchtests/Makefile (bench-math): Add isnan, isinf, and isfinite.
	(CFLAGS-bench-isnan.c, CFLAGS-bench-isinf.c,
	CFLAGS-bench-isfinite.c): New rule.
	* benchtests/isnan-input: New file.
	* benchtests/isinf-input: New file.
	* benchtests/isfinite-input: New file.
---
 benchtests/Makefile        |  5 ++++-
 benchtests/isfinite-inputs | 21 +++++++++++++++++++++
 benchtests/isinf-inputs    | 21 +++++++++++++++++++++
 benchtests/isnan-inputs    | 21 +++++++++++++++++++++
 4 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 benchtests/isfinite-inputs
 create mode 100644 benchtests/isinf-inputs
 create mode 100644 benchtests/isnan-inputs

diff --git a/benchtests/Makefile b/benchtests/Makefile
index cdc89488d6..42bf13b27f 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -24,7 +24,7 @@ include ../Makeconfig
 bench-math := acos acosh asin asinh atan atanh cos cosh exp exp2 log log2 \
 	      modf pow rint sin sincos sinh sqrt tan tanh fmin fmax fminf \
 	      fmaxf powf trunc truncf expf exp2f logf log2f sincosf sinf \
-	      cosf
+	      cosf isnan isinf isfinite
 
 bench-pthread := pthread_once thread_create
 
@@ -88,6 +88,9 @@ CFLAGS-bench-fmax.c += -fno-builtin
 CFLAGS-bench-fmaxf.c += -fno-builtin
 CFLAGS-bench-trunc.c += -fno-builtin
 CFLAGS-bench-truncf.c += -fno-builtin
+CFLAGS-bench-isnan.c += -fsignaling-nans
+CFLAGS-bench-isinf.c += -fsignaling-nans
+CFLAGS-bench-isfinite.c += -fsignaling-nans
 
 ifeq (${BENCHSET},)
 bench-malloc := malloc-thread malloc-simple
diff --git a/benchtests/isfinite-inputs b/benchtests/isfinite-inputs
new file mode 100644
index 0000000000..35a887c9df
--- /dev/null
+++ b/benchtests/isfinite-inputs
@@ -0,0 +1,21 @@
+## includes: math.h
+## args: double
+## ret: int
+0.9
+2.3
+3.7
+3.9
+4.0
+4.7
+5.9
+0x1.000000cf4a2a1p0
+0x1.0000010b239a8p0
+0x1.00000162a932ap0
+0x1.000002d452a11p0
+0x1.000005bc7d86cp0
+## name: INF
+__builtin_inf ()
+-__builtin_inf ()
+## name: NAN
+__builtin_nan ("")
+__builtin_nans ("")
diff --git a/benchtests/isinf-inputs b/benchtests/isinf-inputs
new file mode 100644
index 0000000000..35a887c9df
--- /dev/null
+++ b/benchtests/isinf-inputs
@@ -0,0 +1,21 @@
+## includes: math.h
+## args: double
+## ret: int
+0.9
+2.3
+3.7
+3.9
+4.0
+4.7
+5.9
+0x1.000000cf4a2a1p0
+0x1.0000010b239a8p0
+0x1.00000162a932ap0
+0x1.000002d452a11p0
+0x1.000005bc7d86cp0
+## name: INF
+__builtin_inf ()
+-__builtin_inf ()
+## name: NAN
+__builtin_nan ("")
+__builtin_nans ("")
diff --git a/benchtests/isnan-inputs b/benchtests/isnan-inputs
new file mode 100644
index 0000000000..35a887c9df
--- /dev/null
+++ b/benchtests/isnan-inputs
@@ -0,0 +1,21 @@
+## includes: math.h
+## args: double
+## ret: int
+0.9
+2.3
+3.7
+3.9
+4.0
+4.7
+5.9
+0x1.000000cf4a2a1p0
+0x1.0000010b239a8p0
+0x1.00000162a932ap0
+0x1.000002d452a11p0
+0x1.000005bc7d86cp0
+## name: INF
+__builtin_inf ()
+-__builtin_inf ()
+## name: NAN
+__builtin_nan ("")
+__builtin_nans ("")
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 12/28] math: Use wordsize-64 version for isnan
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (10 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 11/28] benchtests: Add isnan/isinf/isfinite benchmark Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-05 22:45   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 13/28] powerpc: Remove optimized isnan Adhemerval Zanella
                   ` (15 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

  - math.h will use compiler builtin for gcc 4.4+ when built without
    -fsignaling-nans and the builtin is expanded inline for all
    supported architectures.  As an example, there is no intra isnan
    call on libm for the architecture I checked (x86, arm, aarch64,
    and powerpc).

  - The resulting binary difference on 32 bits architecture is minimum
    for the non hotspot symbol.

  - It helps wordsize-64 architectures that use ldbl-opt.

  - It add some code simplification with reduction of duplicated
    implementations.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c: Move to ...
	* sysdeps/ieee754/dbl-64/s_isnan.c: ... here and format code.
---
 sysdeps/ieee754/dbl-64/s_isnan.c             | 17 +++------
 sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c | 40 --------------------
 2 files changed, 6 insertions(+), 51 deletions(-)
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c

diff --git a/sysdeps/ieee754/dbl-64/s_isnan.c b/sysdeps/ieee754/dbl-64/s_isnan.c
index 82723eeb8a..1f1535dea3 100644
--- a/sysdeps/ieee754/dbl-64/s_isnan.c
+++ b/sysdeps/ieee754/dbl-64/s_isnan.c
@@ -10,10 +10,6 @@
  * ====================================================
  */
 
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
-#endif
-
 /*
  * isnan(x) returns 1 is x is nan, else 0;
  * no branching!
@@ -23,17 +19,16 @@ static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
 #include <math_private.h>
 #include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
+#include <stdint.h>
 
-#undef __isnan
 int
 __isnan (double x)
 {
-  int32_t hx, lx;
-  EXTRACT_WORDS (hx, lx, x);
-  hx &= 0x7fffffff;
-  hx |= (uint32_t) (lx | (-lx)) >> 31;
-  hx = 0x7ff00000 - hx;
-  return (int) (((uint32_t) hx) >> 31);
+  int64_t hx;
+  EXTRACT_WORDS64 (hx, x);
+  hx &= UINT64_C (0x7fffffffffffffff);
+  hx = UINT64_C (0x7ff0000000000000) - hx;
+  return (int)(((uint64_t)hx)>>63);
 }
 hidden_def (__isnan)
 weak_alias (__isnan, isnan)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c
deleted file mode 100644
index cd805d157b..0000000000
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* @(#)s_isnan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * isnan(x) returns 1 is x is nan, else 0;
- * no branching!
- */
-
-#include <math.h>
-#include <math_private.h>
-#include <ldbl-classify-compat.h>
-#include <shlib-compat.h>
-#include <stdint.h>
-
-#undef __isnan
-int __isnan(double x)
-{
-	int64_t hx;
-	EXTRACT_WORDS64(hx,x);
-	hx &= UINT64_C(0x7fffffffffffffff);
-	hx = UINT64_C(0x7ff0000000000000) - hx;
-	return (int)(((uint64_t)hx)>>63);
-}
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-#ifdef NO_LONG_DOUBLE
-# if LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-# endif
-weak_alias (__isnan, isnanl)
-#endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 13/28] powerpc: Remove optimized isnan
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (11 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 12/28] math: Use wordsize-64 version for isnan Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-05 22:46   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 14/28] math: Use wordsize-64 version for isinf Adhemerval Zanella
                   ` (14 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

The powerpc isnan optimizations are not really a gain:

  - GCC will call libm iff -fsignaling-nans is used. This usage pattern
    is usually not performance oriented and for such calls PLT overhead
    should dominate execution time.

  - The power5, power6, and power6x are just micro-optimization to
    improve the Load-Hit-Store hazards from floating-point to general
    register transfer, and current GCC already has support to minimize
    it by inserting either extra nops or group dispatch instructions.

  - The power7 uses ftdiv to optimize for some input patterns, but at
    cost of others.  Comparing against generic C implementation built
    for powerpc-linux-gnu-power4 (which uses the hp-timing support on
    benchtests):

    - Generic sysdeps/ieee754 implementation:
      "isnan": {
       "": {
        "duration": 4.98415e+09,
        "iterations": 2.34516e+09,
        "max": 45.925,
        "min": 2.052,
        "mean": 2.12529
       },
       "INF": {
        "duration": 4.74057e+09,
        "iterations": 1.69761e+09,
        "max": 91.01,
        "min": 2.052,
        "mean": 2.79249
       },
       "NAN": {
        "duration": 4.74071e+09,
        "iterations": 1.68768e+09,
        "max": 282.343,
        "min": 2.052,
        "mean": 2.809
       }
      }

    - power7 optimized one:
    $ ./testrun.sh benchtests/bench-isnan
      "isnan": {
       "": {
        "duration": 4.96842e+09,
        "iterations": 2.56297e+09,
        "max": 50.048,
        "min": 1.872,
        "mean": 1.93854
       },
       "INF": {
        "duration": 4.76648e+09,
        "iterations": 1.54213e+09,
        "max": 373.408,
        "min": 2.661,
        "mean": 3.09084
       },
       "NAN": {
        "duration": 4.76845e+09,
        "iterations": 1.54515e+09,
        "max": 51.016,
        "min": 2.736,
        "mean": 3.08607
       }
      }

    So it basically optimizes marginally for normal numbers while
    increasing the latency for other kind of FP.

  - The generic implementation requires getting the floating point
    status, disable the invalid operation bit, and restore the
    floating-point status.  Each operation is costly and requires
    flushing the FP pipeline.

    Using the same scenarion for the previous analysis:

      "isnan": {
       "": {
        "duration": 5.08284e+09,
        "iterations": 6.2898e+08,
        "max": 41.844,
        "min": 8.057,
        "mean": 8.08108
       },
       "INF": {
        "duration": 4.97904e+09,
        "iterations": 6.16176e+08,
        "max": 39.661,
        "min": 8.057,
        "mean": 8.08055
       },
       "NAN": {
        "duration": 4.98695e+09,
        "iterations": 5.95866e+08,
        "max": 29.728,
        "min": 8.345,
        "mean": 8.36925
       }
      }

  - The power8 implementation is just the generic implementation using
    ISA 2.07 mfvsrd instruction (which GCC uses for generic implementation).
    So generic implementation already generates best code for powerpc64le.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/s_isnan.c: Remove file.
	* sysdeps/powerpc/fpu/s_isnanf.S: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/x/powerpc32/power4/fpu/multiarch/Makefile
	(sysdeps_routines): Remove s_isnan-* objects.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power5.S:
	Remove file
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power6.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power7.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power5.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power6.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf.c: Likewise.
	* sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5/fpu/s_isnanf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_isnanf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile (sysdep_calls):
	Remove s_isnan-* objects.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power5.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6x.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_isnanf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S: Likewise.
---
 sysdeps/powerpc/fpu/s_isnan.c                 | 62 -------------
 sysdeps/powerpc/fpu/s_isnanf.S                |  1 -
 sysdeps/powerpc/powerpc32/fpu/s_isnan.S       | 57 ------------
 .../powerpc32/power4/fpu/multiarch/Makefile   |  7 +-
 .../power4/fpu/multiarch/s_isnan-power5.S     | 33 -------
 .../power4/fpu/multiarch/s_isnan-power6.S     | 33 -------
 .../power4/fpu/multiarch/s_isnan-power7.S     | 33 -------
 .../power4/fpu/multiarch/s_isnan-ppc32.S      | 32 -------
 .../powerpc32/power4/fpu/multiarch/s_isnan.c  | 56 ------------
 .../power4/fpu/multiarch/s_isnanf-power5.S    | 28 ------
 .../power4/fpu/multiarch/s_isnanf-power6.S    | 28 ------
 .../powerpc32/power4/fpu/multiarch/s_isnanf.c | 39 --------
 .../powerpc/powerpc32/power5/fpu/s_isnan.S    | 61 -------------
 .../powerpc/powerpc32/power5/fpu/s_isnanf.S   | 45 ----------
 .../powerpc/powerpc32/power6/fpu/s_isnan.S    | 61 -------------
 .../powerpc/powerpc32/power6/fpu/s_isnanf.S   | 44 ---------
 .../powerpc/powerpc32/power7/fpu/s_isnan.S    | 90 -------------------
 .../powerpc/powerpc32/power7/fpu/s_isnanf.S   |  1 -
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  2 -
 .../powerpc64/fpu/multiarch/s_isnan-power5.S  | 32 -------
 .../powerpc64/fpu/multiarch/s_isnan-power6.S  | 32 -------
 .../powerpc64/fpu/multiarch/s_isnan-power6x.S | 32 -------
 .../powerpc64/fpu/multiarch/s_isnan-power7.S  | 32 -------
 .../powerpc64/fpu/multiarch/s_isnan-power8.S  | 32 -------
 .../powerpc64/fpu/multiarch/s_isnan-ppc64.S   | 36 --------
 .../powerpc/powerpc64/fpu/multiarch/s_isnan.c | 71 ---------------
 .../powerpc64/fpu/multiarch/s_isnanf.c        | 44 ---------
 sysdeps/powerpc/powerpc64/fpu/s_isnan.S       | 56 ------------
 .../powerpc/powerpc64/power5/fpu/s_isnan.S    | 60 -------------
 .../powerpc/powerpc64/power6/fpu/s_isnan.S    | 59 ------------
 .../powerpc/powerpc64/power6x/fpu/s_isnan.S   | 58 ------------
 .../powerpc/powerpc64/power7/fpu/s_isnan.S    | 68 --------------
 .../powerpc/powerpc64/power7/fpu/s_isnanf.S   |  1 -
 .../powerpc/powerpc64/power8/fpu/s_isnan.S    | 56 ------------
 .../powerpc/powerpc64/power8/fpu/s_isnanf.S   |  1 -
 35 files changed, 2 insertions(+), 1381 deletions(-)
 delete mode 100644 sysdeps/powerpc/fpu/s_isnan.c
 delete mode 100644 sysdeps/powerpc/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power5.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-ppc32.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power5.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power5.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6x.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isnanf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S

diff --git a/sysdeps/powerpc/fpu/s_isnan.c b/sysdeps/powerpc/fpu/s_isnan.c
deleted file mode 100644
index b62c4cbd0f..0000000000
--- a/sysdeps/powerpc/fpu/s_isnan.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Return 1 if argument is a NaN, else 0.
-   Copyright (C) 1997-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* Ugly kludge to avoid declarations.  */
-#define __isnanf __Xisnanf
-#define isnanf Xisnanf
-#define __GI___isnanf __GI___Xisnanf
-
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <fenv_libc.h>
-
-#undef __isnanf
-#undef isnanf
-#undef __GI___isnanf
-
-
-/* The hidden_proto in include/math.h was obscured by the macro hackery.  */
-__typeof (__isnan) __isnanf;
-hidden_proto (__isnanf)
-
-
-int
-__isnan (double x)
-{
-  fenv_t savedstate;
-  int result;
-  savedstate = fegetenv_register ();
-  reset_fpscr_bit (FPSCR_VE);
-  result = !(x == x);
-  fesetenv_register (savedstate);
-  return result;
-}
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
diff --git a/sysdeps/powerpc/fpu/s_isnanf.S b/sysdeps/powerpc/fpu/s_isnanf.S
deleted file mode 100644
index fc22f678a1..0000000000
--- a/sysdeps/powerpc/fpu/s_isnanf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __isnanf is in s_isnan.c  */
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_isnan.S b/sysdeps/powerpc/powerpc32/fpu/s_isnan.S
deleted file mode 100644
index f28533d40a..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_isnan.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* isnan().  PowerPC32 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.machine power4
-EALIGN (__isnan, 4, 0)
-	mffs	fp0
-	mtfsb0	4*cr6+lt /* reset_fpscr_bit (FPSCR_VE) */
-	fcmpu	cr7,fp1,fp1
-	mtfsf	255,fp0
-	li	r3,0
-	beqlr+	cr7	/* (x == x) then not a NAN */
-	li	r3,1	/* else must be a NAN */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-#ifndef __isnan
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-#endif
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
-
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index 7008e775b7..0b39461a1a 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -1,6 +1,5 @@
 ifeq ($(subdir),math)
-sysdep_routines += s_isnan-power7 s_isnan-power6 s_isnan-power5 s_isnan-ppc32 \
-		   s_isnanf-power6 s_isnanf-power5 s_isinf-power7 \
+sysdep_routines += s_isinf-power7 \
 		   s_isinf-ppc32 s_isinff-ppc32 s_finite-power7 \
 		   s_finite-ppc32 s_finitef-ppc32 \
 		   s_modf-power5+ s_modf-ppc32 \
@@ -8,9 +7,7 @@ sysdep_routines += s_isnan-power7 s_isnan-power6 s_isnan-power5 s_isnan-ppc32 \
 
 libm-sysdep_routines += s_llrintf-power6 s_llrintf-ppc32 s_llrint-power6 \
 			s_llrint-ppc32 s_llround-power6 s_llround-power5+ \
-			s_llround-ppc32 s_isnan-power7 \
-			s_isnan-power6 s_isnan-power5 s_isnan-ppc32 \
-			s_isnanf-power6 s_isnanf-power5 s_isinf-power7 \
+			s_llround-ppc32 s_isinf-power7 \
 			s_isinf-ppc32 s_isinff-ppc32 s_finite-power7 \
 			s_finite-ppc32 s_finitef-ppc32 s_ceil-power5+ \
 			s_ceil-ppc32 s_ceilf-power5+ s_ceilf-ppc32 \
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power5.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power5.S
deleted file mode 100644
index b4bb2bd4bf..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power5.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* isnan().  PowerPC32/POWER5 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power5
-
-#include <sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power6.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power6.S
deleted file mode 100644
index c8a429b1e6..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power6.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* isnan().  PowerPC32/POWER6 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power6
-
-#include <sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power7.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power7.S
deleted file mode 100644
index ae3fc0539b..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-power7.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* isnan().  PowerPC32/POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power7
-
-#include <sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-ppc32.S
deleted file mode 100644
index 4b204ae6cf..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan-ppc32.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-#undef compat_symbol
-#define compat_symbol(a, b, c, d)
-
-#define __isnan __isnan_ppc32
-#undef hidden_def
-#define hidden_def(name)
-  strong_alias (__isnan_ppc32, __GI___isnan)
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c
deleted file mode 100644
index 8a7c31f998..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Multiple versions of isnan.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __isnan __redirect___isnan
-#define __isnanf __redirect___isnanf
-#define __isnanl __redirect___isnanl
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__isnan) __isnan_ppc32 attribute_hidden;
-extern __typeof (__isnan) __isnan_power5 attribute_hidden;
-extern __typeof (__isnan) __isnan_power6 attribute_hidden;
-extern __typeof (__isnan) __isnan_power7 attribute_hidden;
-#undef __isnan
-#undef __isnanf
-#undef __isnanl
-
-libc_ifunc_redirected (__redirect___isnan, __isnan,
-		       (hwcap & PPC_FEATURE_ARCH_2_06)
-		       ? __isnan_power7
-		       : (hwcap & PPC_FEATURE_ARCH_2_05)
-			 ? __isnan_power6
-			 : (hwcap & PPC_FEATURE_POWER5)
-			   ? __isnan_power5
-			   : __isnan_ppc32);
-
-weak_alias (__isnan, isnan)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power5.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power5.S
deleted file mode 100644
index c456d82999..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power5.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* isnanf().  PowerPC32/POWER5 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-
-#define __isnanf __isnanf_power5
-
-#include <sysdeps/powerpc/powerpc32/power5/fpu/s_isnanf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power6.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power6.S
deleted file mode 100644
index 0133cf218f..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf-power6.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* isnanf().  PowerPC32/POWER6 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-
-#define __isnanf __isnanf_power6
-
-#include <sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf.c
deleted file mode 100644
index acb84dbc61..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Multiple versions of isnanf.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-/* Both ppc32 and power7 isnan(double) work for float.  */
-extern __typeof (__isnanf) __isnan_ppc32 attribute_hidden;
-extern __typeof (__isnanf) __isnanf_power5 attribute_hidden;
-extern __typeof (__isnanf) __isnanf_power6 attribute_hidden;
-extern __typeof (__isnanf) __isnan_power7 attribute_hidden;
-
-libc_ifunc_hidden (__isnanf, __isnanf,
-		   (hwcap & PPC_FEATURE_ARCH_2_06)
-		   ? __isnan_power7
-		   : (hwcap & PPC_FEATURE_ARCH_2_05)
-		     ? __isnanf_power6
-		     : (hwcap & PPC_FEATURE_POWER5)
-		       ? __isnanf_power5
-		       : __isnan_ppc32);
-
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
diff --git a/sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S b/sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S
deleted file mode 100644
index 1326973bfc..0000000000
--- a/sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S
+++ /dev/null
@@ -1,61 +0,0 @@
-/* isnan().  PowerPC32 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.machine power5
-EALIGN (__isnan, 4, 0)
-	stwu	r1,-32(r1)
-	cfi_adjust_cfa_offset (32)
-	ori	r1,r1,0
-	stfd	fp1,24(r1)	/* copy FPR to GPR */
-	ori	r1,r1,0
-	lwz	r4,24+HIWORD(r1)
-	lwz	r5,24+LOWORD(r1)
-	lis	r0,0x7ff0	/* const long r0 0x7ff00000 00000000 */
-	clrlwi	r4,r4,1		/* x = fabs(x) */
-	cmpw	cr7,r4,r0	/* if (fabs(x) =< inf) */
-	cmpwi	cr6,r5,0
-	li	r3,0		/* then return 0 */
-	addi	r1,r1,32
-	cfi_adjust_cfa_offset (-32)
-	bltlr+	cr7
-	bgt-	cr7,L(NaN)
-	beqlr+	cr6
-L(NaN):
-	li	r3,1		/* else return 1 */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
-
diff --git a/sysdeps/powerpc/powerpc32/power5/fpu/s_isnanf.S b/sysdeps/powerpc/powerpc32/power5/fpu/s_isnanf.S
deleted file mode 100644
index 1cc495f3a8..0000000000
--- a/sysdeps/powerpc/powerpc32/power5/fpu/s_isnanf.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/* isnan().  PowerPC32 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnanf(x)  */
-	.machine power5
-EALIGN (__isnanf, 4, 0)
-	stwu	r1,-32(r1)
-	cfi_adjust_cfa_offset (32)
-	stfs	fp1,28(r1)	/* copy FPR to GPR */
-	nop
-	nop
-	lwz	r4,28(r1)
-	lis	r0,0x7f80	/* const long r0 0x7f800000 */
-	clrlwi	r4,r4,1		/* x = fabs(x) */
-	cmpw	cr7,r4,r0	/* if (fabs(x) =< inf) */
-	li	r3,0		/* then return 0 */
-	addi	r1,r1,32
-	cfi_adjust_cfa_offset (-32)
-	blelr+	cr7
-L(NaN):
-	li	r3,1		/* else return 1 */
-	blr
-	END (__isnanf)
-
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S
deleted file mode 100644
index d283682a71..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S
+++ /dev/null
@@ -1,61 +0,0 @@
-/* isnan().  PowerPC32 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.machine power6
-EALIGN (__isnan, 4, 0)
-	stwu	r1,-32(r1)
-	cfi_adjust_cfa_offset (32)
-	ori	r1,r1,0
-	stfd	fp1,24(r1)	/* copy FPR to GPR */
-	ori	r1,r1,0
-	lwz	r4,24+HIWORD(r1)
-	lwz	r5,24+LOWORD(r1)
-	lis	r0,0x7ff0	/* const long r0 0x7ff00000 00000000 */
-	clrlwi	r4,r4,1		/* x = fabs(x) */
-	cmpw	cr7,r4,r0	/* if (fabs(x) =< inf) */
-	cmpwi	cr6,r5,0
-	li	r3,0		/* then return 0 */
-	addi	r1,r1,32
-	cfi_adjust_cfa_offset (-32)
-	bltlr+	cr7
-	bgt-	cr7,L(NaN)
-	beqlr+	cr6
-L(NaN):
-	li	r3,1		/* else return 1 */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
-
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S
deleted file mode 100644
index 6e61471cf0..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/* isnanf().  PowerPC32 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnanf(x)  */
-	.machine power6
-EALIGN (__isnanf, 4, 0)
-	stwu	r1,-32(r1)
-	cfi_adjust_cfa_offset (32)
-	ori	r1,r1,0
-	stfs	fp1,24(r1)	/* copy FPR to GPR */
-	ori	r1,r1,0
-	lwz	r4,24(r1)
-	lis	r0,0x7f80	/* const long r0 0x7f800000 */
-	clrlwi	r4,r4,1		/* x = fabs(x) */
-	cmpw	cr7,r4,r0	/* if (fabs(x) =< inf) */
-	li	r3,0		/* then return 0 */
-	addi	r1,r1,32
-	cfi_adjust_cfa_offset (-32)
-	blelr+	cr7
-L(NaN):
-	li	r3,1		/* else return 1 */
-	blr
-	END (__isnanf)
-
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S
deleted file mode 100644
index 524a4a6a32..0000000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S
+++ /dev/null
@@ -1,90 +0,0 @@
-/* isnan().  PowerPC32/POWER7 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.section    .rodata.cst8,"aM",@progbits,8
-	.align 3
-.LC0:   /* 1.0 */
-	.quad	    0x3ff0000000000000
-
-	.section    ".text"
-	.type	    __isnan, @function
-	.machine    power7
-ENTRY (__isnan)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfd	fp0,.LC0-got_label@l(r9)
-
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfd	fp0,.LC0@l(r9)
-#endif
-	ftdiv	cr7,fp1,fp0
-	li	r3,0
-	bflr	30	      /* If not NaN or Inf, finish. */
-
-	/* We have -INF/+INF/NaN or a denormal.  */
-
-	stwu	r1,-16(r1)    /* Allocate stack space.  */
-	stfd	fp1,8(r1)     /* Transfer FP to GPR's.  */
-	ori	2,2,0	      /* Force a new dispatch group.  */
-	lwz     r4,8+HIWORD(r1) /* Load the upper half of the FP value.  */
-	lwz     r5,8+LOWORD(r1) /* Load the lower half of the FP value.  */
-	addi	r1,r1,16      /* Reset the stack pointer.  */
-	lis     r0,0x7ff0     /* Load the upper portion for an INF/NaN.  */
-	clrlwi  r4,r4,1	      /* r4 = abs(r4).  */
-	cmpw    cr7,r4,r0     /* if (abs(r4) <= inf).  */
-	cmpwi   cr6,r5,0      /* r5 == 0x00000000?  */
-	bltlr	cr7	      /* LT means we have a denormal.  */
-	bgt	cr7,L(NaN)    /* GT means we have a NaN.  */
-	beqlr	cr6	      /* EQ means we have +/-INF.  */
-L(NaN):
-	li      r3,1	      /* x == NaN?  */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_isnanf.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_isnanf.S
deleted file mode 100644
index b48c85e0d3..0000000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_isnanf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_isnan.S.  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 36d5e65ee1..a0b5939abe 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -6,8 +6,6 @@ sysdep_calls := s_finite-power8 s_finite-power7 s_finite-ppc64 \
 		s_finitef-ppc64 \
 		s_isinf-power8 s_isinf-ppc64 \
 		s_isinff-ppc64 s_isinf-power7 \
-		s_isnan-power8 s_isnan-power7 s_isnan-power6x s_isnan-power6 \
-		s_isnan-power5 s_isnan-ppc64 \
 		s_modf-power5+ s_modf-ppc64 \
 		s_modff-power5+ s_modff-ppc64
 
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power5.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power5.S
deleted file mode 100644
index 949c51ed12..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power5.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC64/POWER5 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power5
-
-#include <sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6.S
deleted file mode 100644
index e946d78c75..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC64/POWER6 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power6
-
-#include <sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6x.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6x.S
deleted file mode 100644
index 00016225eb..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power6x.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC64/POWER6X version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power6x
-
-#include <sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power7.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power7.S
deleted file mode 100644
index f32b1feaca..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power7.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC64/POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power7
-
-#include <sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S
deleted file mode 100644
index 4f292f146c..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC64/POWER7 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __isnan __isnan_power8
-
-#include <sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-ppc64.S
deleted file mode 100644
index 6c508aea16..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-ppc64.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/* isnan().  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-
-#define __isnan __isnan_ppc64
-#ifdef SHARED
- #undef hidden_def
- #define hidden_def(name) \
-   .globl __GI___isnan ; .set __GI___isnan,__isnan_ppc64
-#endif
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_isnan.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
deleted file mode 100644
index 5aa44eab12..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Multiple versions of isnan.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __isnan __redirect___isnan
-
-/* The following definitions, although not related to the 'double'
-   version of 'isnan', are required to guarantee macro expansions
-   (e.g.: from __isnanf to __redirect_isnanf) in include/math.h, thus
-   compensating for the unintended macro expansions in
-   math/bits/mathcalls-helper-functions.h.  */
-#define __isnanf __redirect___isnanf
-#define __isnanl __redirect___isnanl
-#define __isnanf128 __redirect___isnanf128
-
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__isnan) __isnan_ppc64 attribute_hidden;
-extern __typeof (__isnan) __isnan_power5 attribute_hidden;
-extern __typeof (__isnan) __isnan_power6 attribute_hidden;
-extern __typeof (__isnan) __isnan_power6x attribute_hidden;
-extern __typeof (__isnan) __isnan_power7 attribute_hidden;
-extern __typeof (__isnan) __isnan_power8 attribute_hidden;
-#undef __isnan
-#undef __isnanf
-#undef __isnanl
-#undef __isnanf128
-
-libc_ifunc_redirected (__redirect___isnan, __isnan,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-		       ? __isnan_power8
-		       : (hwcap & PPC_FEATURE_ARCH_2_06)
-			 ? __isnan_power7
-			 : (hwcap & PPC_FEATURE_POWER6_EXT)
-			   ? __isnan_power6x
-			   : (hwcap & PPC_FEATURE_ARCH_2_05)
-			     ? __isnan_power6
-			     : (hwcap & PPC_FEATURE_POWER5)
-			       ? __isnan_power5
-			       : __isnan_ppc64);
-
-weak_alias (__isnan, isnan)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c
deleted file mode 100644
index 5d789ce196..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Multiple versions of isnan.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include "init-arch.h"
-
-/* The double-precision implementation also works for the single one.  */
-extern __typeof (__isnanf) __isnan_ppc64 attribute_hidden;
-extern __typeof (__isnanf) __isnan_power5 attribute_hidden;
-extern __typeof (__isnanf) __isnan_power6 attribute_hidden;
-extern __typeof (__isnanf) __isnan_power6x attribute_hidden;
-extern __typeof (__isnanf) __isnan_power7 attribute_hidden;
-extern __typeof (__isnanf) __isnan_power8 attribute_hidden;
-
-libc_ifunc_hidden (__isnanf, __isnanf,
-		   (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-		   ? __isnan_power8
-		   : (hwcap & PPC_FEATURE_ARCH_2_06)
-		     ? __isnan_power7
-		     : (hwcap & PPC_FEATURE_POWER6_EXT)
-		       ? __isnan_power6x
-		       : (hwcap & PPC_FEATURE_ARCH_2_05)
-			 ? __isnan_power6
-			 : (hwcap & PPC_FEATURE_POWER5)
-			   ? __isnan_power5
-			   : __isnan_ppc64);
-
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_isnan.S b/sysdeps/powerpc/powerpc64/fpu/s_isnan.S
deleted file mode 100644
index ff52c974f8..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_isnan.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/* isnan().  PowerPC64 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.machine power4
-ENTRY_TOCLESS (__isnan, 4)
-	CALL_MCOUNT 0
-	mffs	fp0
-	mtfsb0	4*cr6+lt /* reset_fpscr_bit (FPSCR_VE) */
-	fcmpu	cr7,fp1,fp1
-	mtfsf	255,fp0
-	li	r3,0
-	beqlr+	cr7	/* (x == x) then not a NAN */
-	li	r3,1	/* else must be a NAN */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
-
diff --git a/sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S b/sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S
deleted file mode 100644
index d0c7d81942..0000000000
--- a/sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S
+++ /dev/null
@@ -1,60 +0,0 @@
-/* isnan().  PowerPC64 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.machine power5
-ENTRY_TOCLESS (__isnan, 4)
-	CALL_MCOUNT 0
-	stfd	fp1,-8(r1)	/* copy FPR to GPR */
-	lis	r0,0x7ff0
-	nop			/* insure the following is in a different */
-	nop			/* dispatch group */
-	ld	r4,-8(r1)
-	sldi	r0,r0,32	/* const long r0 0x7ff00000 00000000 */
-	clrldi	r4,r4,1		/* x = fabs(x) */
-	cmpd	cr7,r4,r0	/* if (fabs(x) <= inf) */
-	li	r3,0		/* then return 0 */
-	blelr+	cr7
-	li	r3,1		/* else return 1 */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
-
diff --git a/sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S b/sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S
deleted file mode 100644
index be1c2c4d04..0000000000
--- a/sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S
+++ /dev/null
@@ -1,59 +0,0 @@
-/* isnan().  PowerPC64 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.machine power6
-ENTRY_TOCLESS (__isnan, 4)
-	CALL_MCOUNT 0
-	stfd	fp1,-8(r1)	/* copy FPR to GPR */
-	ori	r1,r1,0
-	ld	r4,-8(r1)
-	lis	r0,0x7ff0
-	sldi	r0,r0,32	/* const long r0 0x7ff00000 00000000 */
-	clrldi	r4,r4,1		/* x = fabs(x) */
-	cmpd	cr7,r4,r0	/* if (fabs(x) <= inf) */
-	li	r3,0		/* then return 0 */
-	blelr+	cr7
-	li	r3,1		/* else return 1 */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
-
diff --git a/sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S b/sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S
deleted file mode 100644
index b32a87a025..0000000000
--- a/sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/* isnan().  PowerPC64 version.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.machine power6
-ENTRY_TOCLESS (__isnan, 4)
-	CALL_MCOUNT 0
-	mftgpr	r4,fp1		/* copy FPR to GPR */
-	lis	r0,0x7ff0
-	ori	r1,r1,0
-	clrldi	r4,r4,1		/* x = fabs(x) */
-	sldi	r0,r0,32	/* const long r0 0x7ff00000 00000000 */
-	cmpd	cr7,r4,r0	/* if (fabs(x) <= inf) */
-	li	r3,0		/* then return 0 */
-	blelr+	cr7
-	li	r3,1		/* else return 1 */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
-
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S b/sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S
deleted file mode 100644
index f7df57fe6a..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S
+++ /dev/null
@@ -1,68 +0,0 @@
-/* isnan().  PowerPC64/POWER7 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isnan(x)  */
-	.section    ".toc","aw"
-.LC0:   /* 1.0 */
-	.tc	    FD_ONE[TC],0x3ff0000000000000
-	.section    ".text"
-	.type	    __isnan, @function
-	.machine    power7
-ENTRY (__isnan, 4)
-	CALL_MCOUNT 0
-	lfd	fp0,.LC0@toc(r2)
-	ftdiv	cr7,fp1,fp0
-	li	r3,0
-	bflr	30	      /* If not NaN, finish.  */
-
-	stfd    fp1,-16(r1)   /* Transfer FP to GPR's.  */
-	ori	2,2,0	      /* Force a new dispatch group.  */
-	ld	r4,-16(r1)    /* Load FP into GPR.  */
-	lis     r0,0x7ff0
-	sldi	r0,r0,32      /* const long r0 0x7ff00000 00000000.  */
-	clrldi	r4,r4,1	      /* x = fabs(x)  */
-	cmpd	cr7,r4,r0     /* if (fabs(x) <= inf)  */
-	blelr	cr7	      /* LE means not NaN.  */
-	li	r3,1	      /* else return 1  */
-	blr
-	END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_isnanf.S b/sysdeps/powerpc/powerpc64/power7/fpu/s_isnanf.S
deleted file mode 100644
index b48c85e0d3..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_isnanf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_isnan.S.  */
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S
deleted file mode 100644
index b8ee9c7db4..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/* isnan().  PowerPC64/POWER8 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#define MFVSRD_R3_V1  .long 0x7c230066     /* mfvsrd  r3,vs1  */
-
-/* int [r3] __isnan([f1] x)  */
-
-ENTRY_TOCLESS (__isnan, 4)
-	CALL_MCOUNT 0
-	MFVSRD_R3_V1
-	lis     r9,0x7ff0
-	clrldi  r3,r3,1       /* r3 = r3 & 0x8000000000000000  */
-	rldicr  r9,r9,32,31   /* r9 = (r9 << 32) & 0xffffffff  */
-	subf    r3,r3,r9
-	rldicl  r3,r3,1,63
-	blr
-END (__isnan)
-
-hidden_def (__isnan)
-weak_alias (__isnan, isnan)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isnan, __isnanf)
-hidden_def (__isnanf)
-weak_alias (__isnanf, isnanf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
-weak_alias (__isnan, isnanl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
-compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S
deleted file mode 100644
index b48c85e0d3..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_isnan.S.  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 14/28] math: Use wordsize-64 version for isinf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (12 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 13/28] powerpc: Remove optimized isnan Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-11 13:13   ` Gabriel F. T. Gomes
  2019-06-13  8:57   ` Szabolcs Nagy
  2019-03-29 13:35 ` [PATCH 15/28] powerpc: Remove optimized isinf Adhemerval Zanella
                   ` (13 subsequent siblings)
  27 siblings, 2 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

  - math.h will use compiler builtin for gcc 4.4+ when built without
    -fsignaling-nans and the builtin is expanded inline for all
    supported architectures.  As an example, there is no intra isnan
    call on libm for the architecture I checked (x86, arm, aarch64,
    and powerpc).

  - The resulting binary difference on 32 bits architecture is minimum
    for the non hotspot symbol.

  - It helps wordsize-64 architectures that use ldbl-opt.

  - It add some code simplification with reduction of duplicated
    implementations.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

        * sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Move to ...
        * sysdeps/ieee754/dbl-64/s_isinf.c: ... here and format code.
---
 sysdeps/ieee754/dbl-64/s_isinf.c             | 15 ++++-----
 sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c | 34 --------------------
 2 files changed, 6 insertions(+), 43 deletions(-)
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c

diff --git a/sysdeps/ieee754/dbl-64/s_isinf.c b/sysdeps/ieee754/dbl-64/s_isinf.c
index 93eb65c147..e5300fd2a5 100644
--- a/sysdeps/ieee754/dbl-64/s_isinf.c
+++ b/sysdeps/ieee754/dbl-64/s_isinf.c
@@ -4,10 +4,6 @@
  * Public domain.
  */
 
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
-#endif
-
 /*
  * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
  * no branching!
@@ -21,11 +17,12 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
 int
 __isinf (double x)
 {
-  int32_t hx, lx;
-  EXTRACT_WORDS (hx, lx, x);
-  lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
-  lx |= -lx;
-  return ~(lx >> 31) & (hx >> 30);
+  int64_t ix;
+  EXTRACT_WORDS64 (ix,x);
+  int64_t t = ix & UINT64_C (0x7fffffffffffffff);
+  t ^= UINT64_C (0x7ff0000000000000);
+  t |= -t;
+  return ~(t >> 63) & (ix >> 62);
 }
 hidden_def (__isinf)
 weak_alias (__isinf, isinf)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c
deleted file mode 100644
index 2b427a8b4c..0000000000
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
- * Public domain.
- */
-
-/*
- * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
- * no branching!
- */
-
-#include <math.h>
-#include <math_private.h>
-#include <ldbl-classify-compat.h>
-#include <shlib-compat.h>
-
-int
-__isinf (double x)
-{
-	int64_t ix;
-	EXTRACT_WORDS64(ix,x);
-	int64_t t = ix & UINT64_C(0x7fffffffffffffff);
-	t ^= UINT64_C(0x7ff0000000000000);
-	t |= -t;
-	return ~(t >> 63) & (ix >> 62);
-}
-hidden_def (__isinf)
-weak_alias (__isinf, isinf)
-#ifdef NO_LONG_DOUBLE
-# if LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
-compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
-# endif
-weak_alias (__isinf, isinfl)
-#endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 15/28] powerpc: Remove optimized isinf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (13 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 14/28] math: Use wordsize-64 version for isinf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-11 13:45   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 16/28] math: Use wordsize-64 version for finite Adhemerval Zanella
                   ` (12 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

The powerpc isinf optimizations onyl adds complexity:

  - GCC will call libm iff -fsignaling-nans is used. This usage pattern
    is usually not performance oriented and for such calls PLT overhead
    should dominate execution time.

  - The power7 uses ftdiv to optimize for some input pattern and branch
    implementation for INF and denormal that does:

    return (ix & UINT64_C (0x7fffffffffffffff)) == UINT64_C (0x7ff0000000000000)

    Although it does show slight better latency than generic algorithm,
    it is only for power7 and requires it to override it for power8.

  - The power8 implementation is just the generic implementation using
    ISA 2.07 mfvsrd instruction (which GCC uses for generic implementation).
    So generic implementation is already the best option for powerpc64le.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
	(sysdeps_routines, libm-sysdep_routines): Remove s_isinf*
	objects.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-power7.S:
	Remove file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff.c: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_isinff.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile usysdep_call):
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff.c: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_isinff.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_isinff.S: Likewise.
---
 .../powerpc32/power4/fpu/multiarch/Makefile   |  6 +-
 .../power4/fpu/multiarch/s_isinf-power7.S     | 33 -------
 .../power4/fpu/multiarch/s_isinf-ppc32.c      | 33 -------
 .../powerpc32/power4/fpu/multiarch/s_isinf.c  | 50 -----------
 .../power4/fpu/multiarch/s_isinff-ppc32.c     | 31 -------
 .../powerpc32/power4/fpu/multiarch/s_isinff.c | 35 --------
 .../powerpc/powerpc32/power7/fpu/s_isinf.S    | 85 -------------------
 .../powerpc/powerpc32/power7/fpu/s_isinff.S   |  1 -
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  2 -
 .../powerpc64/fpu/multiarch/s_isinf-power7.S  | 32 -------
 .../powerpc64/fpu/multiarch/s_isinf-power8.S  | 32 -------
 .../powerpc64/fpu/multiarch/s_isinf-ppc64.c   | 33 -------
 .../powerpc/powerpc64/fpu/multiarch/s_isinf.c | 62 --------------
 .../powerpc64/fpu/multiarch/s_isinff-ppc64.c  | 31 -------
 .../powerpc64/fpu/multiarch/s_isinff.c        | 38 ---------
 .../powerpc/powerpc64/power7/fpu/s_isinf.S    | 69 ---------------
 .../powerpc/powerpc64/power7/fpu/s_isinff.S   |  1 -
 .../powerpc/powerpc64/power8/fpu/s_isinf.S    | 61 -------------
 .../powerpc/powerpc64/power8/fpu/s_isinff.S   |  1 -
 19 files changed, 2 insertions(+), 634 deletions(-)
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_isinff.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_isinff.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_isinff.S

diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index 0b39461a1a..c7b9d48094 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -1,14 +1,12 @@
 ifeq ($(subdir),math)
-sysdep_routines += s_isinf-power7 \
-		   s_isinf-ppc32 s_isinff-ppc32 s_finite-power7 \
+sysdep_routines += s_finite-power7 \
 		   s_finite-ppc32 s_finitef-ppc32 \
 		   s_modf-power5+ s_modf-ppc32 \
 		   s_modff-power5+ s_modff-ppc32
 
 libm-sysdep_routines += s_llrintf-power6 s_llrintf-ppc32 s_llrint-power6 \
 			s_llrint-ppc32 s_llround-power6 s_llround-power5+ \
-			s_llround-ppc32 s_isinf-power7 \
-			s_isinf-ppc32 s_isinff-ppc32 s_finite-power7 \
+			s_llround-ppc32 s_finite-power7 \
 			s_finite-ppc32 s_finitef-ppc32 s_ceil-power5+ \
 			s_ceil-ppc32 s_ceilf-power5+ s_ceilf-ppc32 \
 			s_floor-power5+ s_floor-ppc32 s_floorf-power5+ \
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-power7.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-power7.S
deleted file mode 100644
index 0e6e61352d..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-power7.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* isinf().  PowerPC32/POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __isinf __isinf_power7
-
-#include <sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-ppc32.c
deleted file mode 100644
index 09e51c9891..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf-ppc32.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* isinf().  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define __isinf __isinf_ppc32
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__isinf_ppc32, __GI___isinf, __isinf_ppc32);
-#endif
-
-#include <sysdeps/ieee754/dbl-64/s_isinf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c
deleted file mode 100644
index c115c7fef1..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Multiple versions of isinf.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __isinf __redirect___isinf
-#define __isinff __redirect___isinff
-#define __isinfl __redirect___isinfl
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__isinf) __isinf_ppc32 attribute_hidden;
-extern __typeof (__isinf) __isinf_power7 attribute_hidden;
-#undef __isinf
-#undef __isinff
-#undef __isinfl
-
-libc_ifunc_redirected (__redirect___isinf,  __isinf,
-		       (hwcap & PPC_FEATURE_ARCH_2_06)
-		       ? __isinf_power7
-		       : __isinf_ppc32);
-
-weak_alias (__isinf, isinf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isinf, __isinfl)
-weak_alias (__isinf, isinfl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
-compat_symbol (libc, isinf, isinfl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff-ppc32.c
deleted file mode 100644
index 8299fda5fa..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff-ppc32.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* isinff().  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-
-#define __isinff __isinff_ppc32
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__isinff_ppc32, __GI___isinff, __isinff_ppc32);
-#endif
-
-#include <sysdeps/ieee754/flt-32/s_isinff.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff.c
deleted file mode 100644
index 92f078a0db..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Multiple versions of isinf.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __isinff __redirect___isinff
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__isinff) __isinff_ppc32 attribute_hidden;
-/* The power7 isinf(double) works for float.  */
-extern __typeof (__isinff) __isinf_power7 attribute_hidden;
-#undef __isinff
-
-libc_ifunc_redirected (__redirect___isinff,  __isinff,
-		       (hwcap & PPC_FEATURE_ARCH_2_06)
-		       ? __isinf_power7
-		       : __isinff_ppc32);
-
-weak_alias (__isinff, isinff)
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S
deleted file mode 100644
index 9cd45eb428..0000000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S
+++ /dev/null
@@ -1,85 +0,0 @@
-/* isinf().  PowerPC32/POWER7 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isinf(x)  */
-	.section    .rodata.cst8,"aM",@progbits,8
-	.align 3
-.LC0:   /* 1.0 */
-	.quad	    0x3ff0000000000000
-
-	.section    ".text"
-	.type	    __isinf, @function
-	.machine    power7
-ENTRY (__isinf)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfd	fp0,.LC0-got_label@l(r9)
-
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfd	fp0,.LC0@l(r9)
-#endif
-	ftdiv	cr7,fp1,fp0
-	li	r3,0
-	bflr    29	      /* If not INF, return.  */
-
-	/* Either we have +INF or -INF.  */
-
-	stwu    r1,-16(r1)    /* Allocate stack space.  */
-	stfd    fp1,8(r1)     /* Transfer FP to GPR's.  */
-	ori	2,2,0	      /* Force a new dispatch group.  */
-	lhz	r4,8+HISHORT(r1) /* Fetch the upper 16 bits of the FP value
-				    (biased exponent and sign bit).  */
-	addi	r1,r1,16      /* Reset the stack pointer.  */
-	cmpwi	cr7,r4,0x7ff0 /* r4 == 0x7ff0?  */
-	li	r3,1
-	beqlr   cr7	      /* EQ means INF, otherwise -INF.  */
-	li      r3,-1
-	blr
-	END (__isinf)
-
-hidden_def (__isinf)
-weak_alias (__isinf, isinf)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isinf, __isinff)
-hidden_def (__isinff)
-weak_alias (__isinff, isinff)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isinf, __isinfl)
-weak_alias (__isinf, isinfl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
-compat_symbol (libc, isinf, isinfl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_isinff.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_isinff.S
deleted file mode 100644
index be759e091e..0000000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_isinff.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_isinf.S.  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index a0b5939abe..3a2051d97b 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -4,8 +4,6 @@ ifeq ($(subdir),math)
 # prefixed with  m_.
 sysdep_calls := s_finite-power8 s_finite-power7 s_finite-ppc64 \
 		s_finitef-ppc64 \
-		s_isinf-power8 s_isinf-ppc64 \
-		s_isinff-ppc64 s_isinf-power7 \
 		s_modf-power5+ s_modf-ppc64 \
 		s_modff-power5+ s_modff-ppc64
 
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power7.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power7.S
deleted file mode 100644
index 28aeba9e66..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power7.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isinf().  PowerPC64/POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __isinf __isinf_power7
-
-#include <sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power8.S
deleted file mode 100644
index e9ccdabc5b..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-power8.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isinf().  PowerPC64/POWER8 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __isinf __isinf_power8
-
-#include <sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-ppc64.c
deleted file mode 100644
index b919394512..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf-ppc64.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* isinf().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define __isinf __isinf_ppc64
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__isinf_ppc64, __GI___isinf, __isinf_ppc64);
-#endif
-
-#include <sysdeps/ieee754/dbl-64/s_isinf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c
deleted file mode 100644
index f5b9044473..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Multiple versions of isinf.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __isinf __redirect___isinf
-
-/* The following definitions, although not related to the 'double'
-   version of 'isinf', are required to guarantee macro expansions
-   (e.g.: from __isinff to __redirect_isinff) in include/math.h, thus
-   compensating for the unintended macro expansions in
-   math/bits/mathcalls-helper-functions.h.  */
-#define __isinff __redirect___isinff
-#define __isinfl __redirect___isinfl
-#define __isinff128 __redirect___isinff128
-
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__isinf) __isinf_ppc64 attribute_hidden;
-extern __typeof (__isinf) __isinf_power7 attribute_hidden;
-extern __typeof (__isinf) __isinf_power8 attribute_hidden;
-#undef __isinf
-#undef __isinff
-#undef __isinfl
-#undef __isinff128
-
-libc_ifunc_redirected (__redirect___isinf, __isinf,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-		       ? __isinf_power8
-		       : (hwcap & PPC_FEATURE_ARCH_2_06)
-			 ? __isinf_power7
-			 : __isinf_ppc64);
-
-weak_alias (__isinf, isinf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isinf, __isinfl)
-weak_alias (__isinf, isinfl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
-compat_symbol (libc, isinf, isinfl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff-ppc64.c
deleted file mode 100644
index ac5274b4c1..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff-ppc64.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* isinff().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-
-#define __isinff __isinff_ppc64
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__isinff_ppc64, __GI___isinff, __isinff_ppc64);
-#endif
-
-#include <sysdeps/ieee754/flt-32/s_isinff.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff.c
deleted file mode 100644
index 16feaee3b8..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Multiple versions of isinf.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __isinff __redirect___isinff
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__isinff) __isinff_ppc64 attribute_hidden;
-/* The double-precision version also works for single-precision.  */
-extern __typeof (__isinff) __isinf_power7 attribute_hidden;
-extern __typeof (__isinff) __isinf_power8 attribute_hidden;
-#undef __isinff
-
-libc_ifunc_redirected (__redirect___isinff, __isinff,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-		       ? __isinf_power8
-		       : (hwcap & PPC_FEATURE_ARCH_2_06)
-			 ? __isinf_power7
-			 : __isinff_ppc64);
-
-weak_alias (__isinff, isinff)
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S b/sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S
deleted file mode 100644
index aed9d74d35..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S
+++ /dev/null
@@ -1,69 +0,0 @@
-/* isinf().  PowerPC64/POWER7 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __isinf(x)  */
-	.section    ".toc","aw"
-.LC0:   /* 1.0 */
-	.tc	    FD_ONE[TC],0x3ff0000000000000
-	.section    ".text"
-	.type	    __isinf, @function
-	.machine    power7
-ENTRY (__isinf, 4)
-	CALL_MCOUNT 0
-	lfd	fp0,.LC0@toc(r2)
-	ftdiv	cr7,fp1,fp0
-	li	r3,0
-	bflr    29	      /* If not INF, return.  */
-
-	/* Either we have -INF/+INF or a denormal.  */
-
-	stfd    fp1,-16(r1)   /* Transfer FP to GPR's.  */
-	ori	2,2,0	      /* Force a new dispatch group.  */
-	lhz	r4,-16+HISHORT(r1)  /* Fetch the upper 16 bits of the FP value
-				    (biased exponent and sign bit).  */
-	cmpwi	cr7,r4,0x7ff0 /* r4 == 0x7ff0?  */
-	li	r3,1
-	beqlr   cr7	      /* EQ means INF, otherwise -INF.  */
-	li      r3,-1
-	blr
-	END (__isinf)
-
-hidden_def (__isinf)
-weak_alias (__isinf, isinf)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isinf, __isinff)
-hidden_def (__isinff)
-weak_alias (__isinff, isinff)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isinf, __isinfl)
-weak_alias (__isinf, isinfl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
-compat_symbol (libc, isinf, isinfl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_isinff.S b/sysdeps/powerpc/powerpc64/power7/fpu/s_isinff.S
deleted file mode 100644
index be759e091e..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_isinff.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_isinf.S.  */
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S
deleted file mode 100644
index 1fb2851a84..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S
+++ /dev/null
@@ -1,61 +0,0 @@
-/* isinf().  PowerPC64/POWER8 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#define MFVSRD_R3_V1  .long 0x7c230066     /* mfvsrd  r3,vs1  */
-
-/* int [r3] __isinf([fp1] x)  */
-
-ENTRY_TOCLESS (__isinf, 4)
-	CALL_MCOUNT 0
-	MFVSRD_R3_V1
-	lis     r9,0x7ff0     /* r9 = 0x7ff0  */
-	rldicl  r10,r3,0,1    /* r10 = r3 & (0x8000000000000000)  */
-	sldi    r9,r9,32      /* r9 = r9 << 52  */
-	cmpd    cr7,r10,r9    /* fp1 & 0x7ff0000000000000 ?  */
-	beq     cr7,L(inf)
-	li      r3,0          /* Not inf  */
-	blr
-L(inf):
-	sradi   r3,r3,63      /* r3 = r3 >> 63  */
-	ori     r3,r3,1       /* r3 = r3 | 0x1  */
-	blr
-END (__isinf)
-
-hidden_def (__isinf)
-weak_alias (__isinf, isinf)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__isinf, __isinff)
-hidden_def (__isinff)
-weak_alias (__isinff, isinff)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__isinf, __isinfl)
-weak_alias (__isinf, isinfl)
-#endif
-
-#if !IS_IN (libm)
-# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
-compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
-compat_symbol (libc, isinf, isinfl, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_isinff.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_isinff.S
deleted file mode 100644
index be759e091e..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_isinff.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_isinf.S.  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 16/28] math: Use wordsize-64 version for finite
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (14 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 15/28] powerpc: Remove optimized isinf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-11 16:20   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 17/28] powerpc: Remove optimized finite Adhemerval Zanella
                   ` (11 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

  - math.h will use compiler builtin for gcc 4.4+ when built without
    -fsignaling-nans and the builtin is expanded inline for all
    supported architectures.  As an example, there is no intra finite
    call on libm for the architecture I checked (x86, arm, aarch64,
    and powerpc).

  - The resulting binary difference on 32 bits architecture is minimum
    for the non hotspot symbol.

  - It helps wordsize-64 architectures that use ldbl-opt.

  - It add some code simplification with reduction of duplicated
    implementations.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c: Move to ...
	* sysdeps/ieee754/dbl-64/s_finite.c: ... here and format code.
---
 sysdeps/ieee754/dbl-64/s_finite.c             | 22 +++-------
 sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c | 43 -------------------
 2 files changed, 7 insertions(+), 58 deletions(-)
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c

diff --git a/sysdeps/ieee754/dbl-64/s_finite.c b/sysdeps/ieee754/dbl-64/s_finite.c
index da1519b1d0..98a40fbff6 100644
--- a/sysdeps/ieee754/dbl-64/s_finite.c
+++ b/sysdeps/ieee754/dbl-64/s_finite.c
@@ -1,4 +1,3 @@
-/* @(#)s_finite.c 5.1 93/09/24 */
 /*
  * ====================================================
  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
  * ====================================================
  */
 
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
-#endif
-
 /*
  * finite(x) returns 1 is x is finite, else 0;
  * no branching!
@@ -23,18 +18,15 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
 #include <math_private.h>
 #include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
+#include <stdint.h>
 
-#undef __finite
-
-#ifndef FINITE
-# define FINITE __finite
-#endif
-
-int FINITE(double x)
+int
+__finite (double x)
 {
-  int32_t hx;
-  GET_HIGH_WORD (hx, x);
-  return (int) ((uint32_t) ((hx & 0x7ff00000) - 0x7ff00000) >> 31);
+  int64_t lx;
+  EXTRACT_WORDS64 (lx,x);
+  return (int)((uint64_t)((lx & INT64_C(0x7ff0000000000000))
+			  - INT64_C (0x7ff0000000000000)) >> 63);
 }
 hidden_def (__finite)
 weak_alias (__finite, finite)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
deleted file mode 100644
index 40676924fe..0000000000
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * finite(x) returns 1 is x is finite, else 0;
- * no branching!
- */
-
-#include <math.h>
-#include <math_private.h>
-#include <ldbl-classify-compat.h>
-#include <shlib-compat.h>
-#include <stdint.h>
-
-#undef __finite
-int
-__finite(double x)
-{
-  int64_t lx;
-  EXTRACT_WORDS64(lx,x);
-  return (int)((uint64_t)((lx&INT64_C(0x7ff0000000000000))-INT64_C(0x7ff0000000000000))>>63);
-}
-hidden_def (__finite)
-weak_alias (__finite, finite)
-#ifdef NO_LONG_DOUBLE
-# if LDBL_CLASSIFY_COMPAT
-#  if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
-compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
-#  endif
-#  if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_23)
-compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
-#  endif
-# endif
-weak_alias (__finite, finitel)
-#endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 17/28] powerpc: Remove optimized finite
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (15 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 16/28] math: Use wordsize-64 version for finite Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-11 18:08   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 18/28] powerpc: refactor powerpc64 lrint/lrintf/llrint/llrintf Adhemerval Zanella
                   ` (10 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

The powerpc finite optimization do not show much gain:

  - GCC will call libm iff -fsignaling-nans is used. This usage pattern
    is usually not performance oriented and for such calls PLT overhead
    should dominate execution time.

  - The power7 uses ftdiv to optimize for some input patterns, but at
    cost of others.  Comparing against generic C implementation built
    for powerpc64-linux-gnu-power7 (--with-cpu=power7):

    - Generic sysdeps/ieee754 implementation:
       "isfinite": {
        "": {
         "duration": 5.0082e+09,
         "iterations": 2.45299e+09,
         "max": 43.824,
         "min": 2.008,
         "mean": 2.04167
        },
        "INF": {
         "duration": 4.66554e+09,
         "iterations": 2.28288e+09,
         "max": 35.73,
         "min": 2.008,
         "mean": 2.04371
        },
        "NAN": {
         "duration": 4.66274e+09,
         "iterations": 2.28716e+09,
         "max": 34.161,
         "min": 2.009,
         "mean": 2.03866
        }
       }

    - power7 optimized one:
       "isfinite": {
        "": {
         "duration": 4.99111e+09,
         "iterations": 2.65566e+09,
         "max": 25.015,
         "min": 1.716,
         "mean": 1.87942
        },
        "INF": {
         "duration": 4.6783e+09,
         "iterations": 2.0999e+09,
         "max": 35.264,
         "min": 1.868,
         "mean": 2.22787
        },
        "NAN": {
         "duration": 4.67915e+09,
         "iterations": 2.08678e+09,
         "max": 38.099,
         "min": 1.869,
         "mean": 2.24228
        }
       }

     So it basically optimizes marginally for normal numbers while
     increasing the latency for other kind of FP.

  - The power8 implementation is just the generic implementation using
    ISA 2.07 mfvsrd instruction (which GCC uses for generic implementation).
    So generic implementation is the best option for powerpc64le.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
	(sysdeps_routines, libm-sysdep_routines): Remove s_finite*
	objects.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-power7.S:
	Remove file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile usysdep_call):
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_finitef.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_finitef.S: Likewise.
---
 .../powerpc32/power4/fpu/multiarch/Makefile   |  7 +-
 .../power4/fpu/multiarch/s_finite-power7.S    | 33 -------
 .../power4/fpu/multiarch/s_finite-ppc32.c     | 33 -------
 .../powerpc32/power4/fpu/multiarch/s_finite.c | 57 ------------
 .../power4/fpu/multiarch/s_finitef-ppc32.c    | 31 -------
 .../power4/fpu/multiarch/s_finitef.c          | 34 -------
 .../powerpc/powerpc32/power7/fpu/s_finite.S   | 93 -------------------
 .../powerpc/powerpc32/power7/fpu/s_finitef.S  |  1 -
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  4 +-
 .../powerpc64/fpu/multiarch/s_finite-power7.S | 32 -------
 .../powerpc64/fpu/multiarch/s_finite-power8.S | 32 -------
 .../powerpc64/fpu/multiarch/s_finite-ppc64.c  | 34 -------
 .../powerpc64/fpu/multiarch/s_finite.c        | 69 --------------
 .../powerpc64/fpu/multiarch/s_finitef-ppc64.c | 32 -------
 .../powerpc64/fpu/multiarch/s_finitef.c       | 37 --------
 .../powerpc/powerpc64/power7/fpu/s_finite.S   | 70 --------------
 .../powerpc/powerpc64/power7/fpu/s_finitef.S  |  1 -
 .../powerpc/powerpc64/power8/fpu/s_finite.S   | 56 -----------
 .../powerpc/powerpc64/power8/fpu/s_finitef.S  |  1 -
 19 files changed, 3 insertions(+), 654 deletions(-)
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_finitef.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_finitef.S

diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index c7b9d48094..51b13fe33a 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -1,13 +1,10 @@
 ifeq ($(subdir),math)
-sysdep_routines += s_finite-power7 \
-		   s_finite-ppc32 s_finitef-ppc32 \
-		   s_modf-power5+ s_modf-ppc32 \
+sysdep_routines += s_modf-power5+ s_modf-ppc32 \
 		   s_modff-power5+ s_modff-ppc32
 
 libm-sysdep_routines += s_llrintf-power6 s_llrintf-ppc32 s_llrint-power6 \
 			s_llrint-ppc32 s_llround-power6 s_llround-power5+ \
-			s_llround-ppc32 s_finite-power7 \
-			s_finite-ppc32 s_finitef-ppc32 s_ceil-power5+ \
+			s_llround-ppc32 s_ceil-power5+ \
 			s_ceil-ppc32 s_ceilf-power5+ s_ceilf-ppc32 \
 			s_floor-power5+ s_floor-ppc32 s_floorf-power5+ \
 			s_floorf-ppc32 s_round-power5+ s_round-ppc32 \
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-power7.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-power7.S
deleted file mode 100644
index 0cde9f1cd1..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-power7.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* finite().  PowerPC32/POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __finite __finite_power7
-
-#include <sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-ppc32.c
deleted file mode 100644
index c03a26e00f..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-ppc32.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* finite().  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define FINITE __finite_ppc32
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__finite_ppc32, __GI___finite, __finite_ppc32);
-#endif
-
-#include <sysdeps/ieee754/dbl-64/s_finite.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c
deleted file mode 100644
index 677b71baf3..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Multiple versions of finite.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __finite __redirect___finite
-#define __finitef __redirect___finitef
-#define __finitel __redirect___finitel
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__finite) __finite_ppc32 attribute_hidden;
-extern __typeof (__finite) __finite_power7 attribute_hidden;
-#undef __finite
-#undef __finitef
-#undef __finitel
-
-libc_ifunc_redirected (__redirect___finite,  __finite,
-		       (hwcap & PPC_FEATURE_ARCH_2_06)
-		       ? __finite_power7
-		       : __finite_ppc32);
-
-weak_alias (__finite, finite)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__finite, __finitel)
-weak_alias (__finite, finitel)
-#endif
-
-#if IS_IN (libm)
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
-compat_symbol (libm, finite, finitel, GLIBC_2_0);
-# endif
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_1)
-compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
-# endif
-#else
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
-compat_symbol (libc, finite, finitel, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef-ppc32.c
deleted file mode 100644
index e43c7a54bc..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef-ppc32.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* finitef().  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-
-#define FINITEF __finitef_ppc32
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__finitef_ppc32, __GI___finitef, __finitef_ppc32);
-#endif
-
-#include <sysdeps/ieee754/flt-32/s_finitef.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c
deleted file mode 100644
index da4780551e..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Multiple versions of finitef.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __finitef __redirect___finitef
-#include <math.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__finitef) __finitef_ppc32 attribute_hidden;
-/* The power7 finite(double) works for float.  */
-extern __typeof (__finitef) __finite_power7 attribute_hidden;
-#undef __finitef
-
-libc_ifunc_redirected  (__redirect___finitef, __finitef,
-			(hwcap & PPC_FEATURE_ARCH_2_06)
-			? __finite_power7
-			: __finitef_ppc32);
-
-weak_alias (__finitef, finitef)
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S
deleted file mode 100644
index 07fa8ae7b7..0000000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S
+++ /dev/null
@@ -1,93 +0,0 @@
-/* finite().  PowerPC32/POWER7 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __finite(x)  */
-	.section    .rodata.cst8,"aM",@progbits,8
-	.align 3
-.LC0:   /* 1.0 */
-	.quad	    0x3ff0000000000000
-
-	.section    ".text"
-	.type	    __finite, @function
-	.machine    power7
-ENTRY (__finite)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	lfd	fp0,.LC0-got_label@l(r9)
-
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfd	fp0,.LC0@l(r9)
-#endif
-	ftdiv	cr7,fp1,fp0
-	li	r3,1
-	bflr	30
-
-	/* We have -INF/+INF/NaN or a denormal.  */
-
-	stwu	r1,-16(r1)    /* Allocate stack space.  */
-	stfd    fp1,8(r1)     /* Transfer FP to GPR's.  */
-
-	ori	2,2,0	      /* Force a new dispatch group.  */
-	lhz	r0,8+HISHORT(r1) /* Fetch the upper 16 bits of the FP value
-				    (biased exponent and sign bit).  */
-	clrlwi	r0,r0,17      /* r0 = abs(r0).  */
-	addi	r1,r1,16      /* Reset the stack pointer.  */
-	cmpwi	cr7,r0,0x7ff0 /* r4 == 0x7ff0?.  */
-	bltlr	cr7	      /* LT means we have a denormal.  */
-	li	r3,0
-	blr
-	END (__finite)
-
-hidden_def (__finite)
-weak_alias (__finite, finite)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__finite, __finitef)
-hidden_def (__finitef)
-weak_alias (__finitef, finitef)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__finite, __finitel)
-weak_alias (__finite, finitel)
-#endif
-
-#if IS_IN (libm)
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
-compat_symbol (libm, finite, finitel, GLIBC_2_0)
-# endif
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_1)
-compat_symbol (libm, __finite, __finitel, GLIBC_2_1)
-# endif
-#else
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
-compat_symbol (libc, finite, finitel, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S b/sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S
deleted file mode 100644
index 54bd94176d..0000000000
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_finite.S.  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 3a2051d97b..4aa7fd6295 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -2,9 +2,7 @@ ifeq ($(subdir),math)
 # These functions are built both for libc and libm because they're required
 # by printf.  While the libc objects have the prefix s_, the libm ones are
 # prefixed with  m_.
-sysdep_calls := s_finite-power8 s_finite-power7 s_finite-ppc64 \
-		s_finitef-ppc64 \
-		s_modf-power5+ s_modf-ppc64 \
+sysdep_calls := s_modf-power5+ s_modf-ppc64 \
 		s_modff-power5+ s_modff-ppc64
 
 sysdep_routines += $(sysdep_calls)
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S
deleted file mode 100644
index c360c3a8db..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC64/POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __finite __finite_power7
-
-#include <sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S
deleted file mode 100644
index 8fa57e222e..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* isnan().  PowerPC64/POWER7 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, symbol, ver)
-
-#define __finite __finite_power8
-
-#include <sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c
deleted file mode 100644
index 59cc8ba168..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* finite().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define FINITE __finite_ppc64
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__finite_ppc64, __GI___finite, __finite_ppc64);
-#endif
-
-#include <sysdeps/ieee754/dbl-64/s_finite.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
deleted file mode 100644
index 4f88a221cc..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Multiple versions of finite.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __finite __redirect___finite
-
-/* The following definitions, although not related to the 'double'
-   version of 'finite', are required to guarantee macro expansions
-   (e.g.: from __finitef to __redirect_finitef) in include/math.h, thus
-   compensating for the unintended macro expansions in
-   math/bits/mathcalls-helper-functions.h.  */
-#define __finitef __redirect___finitef
-#define __finitel __redirect___finitel
-#define __finitef128 __redirect___finitef128
-
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__finite) __finite_ppc64 attribute_hidden;
-extern __typeof (__finite) __finite_power7 attribute_hidden;
-extern __typeof (__finite) __finite_power8 attribute_hidden;
-#undef __finite
-#undef __finitef
-#undef __finitel
-#undef __finitef128
-
-libc_ifunc_redirected (__redirect___finite, __finite,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-		       ? __finite_power8
-		       : (hwcap & PPC_FEATURE_ARCH_2_06)
-			 ? __finite_power7
-			 : __finite_ppc64);
-
-weak_alias (__finite, finite)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__finite, __finitel)
-weak_alias (__finite, finitel)
-#endif
-
-#if IS_IN (libm)
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
-compat_symbol (libm, finite, finitel, GLIBC_2_0);
-# endif
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_1)
-compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
-# endif
-#else
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
-compat_symbol (libc, finite, finitel, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c
deleted file mode 100644
index 77af76d3ef..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* finitef().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-
-#define FINITEF __finitef_ppc64
-#ifdef SHARED
-# undef hidden_def
-# define hidden_def(a) \
-   __hidden_ver1 (__finitef_ppc64, __GI___finitef, __finitef_ppc64);
-#endif
-
-#include <sysdeps/ieee754/flt-32/s_finitef.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c
deleted file mode 100644
index cde669e5e3..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Multiple versions of finitef.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __finitef __redirect___finitef
-#include <math.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__finitef) __finitef_ppc64 attribute_hidden;
-/* The double-precision version also works for single-precision.  */
-extern __typeof (__finitef) __finite_power7 attribute_hidden;
-extern __typeof (__finitef) __finite_power8 attribute_hidden;
-#undef __finitef
-
-libc_ifunc_redirected (__redirect___finitef, __finitef,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-		       ? __finite_power8
-		       : (hwcap & PPC_FEATURE_ARCH_2_06)
-			 ? __finite_power7
-			 : __finitef_ppc64);
-
-weak_alias (__finitef, finitef)
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S b/sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S
deleted file mode 100644
index 5b5746c9a5..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S
+++ /dev/null
@@ -1,70 +0,0 @@
-/* finite().  PowerPC64/POWER7 version.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   Contributed by Luis Machado <luisgpm@br.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* int __finite(x)  */
-	.section    ".toc","aw"
-.LC0:   /* 1.0 */
-	.tc	    FD_ONE[TC],0x3ff0000000000000
-	.section    ".text"
-	.type	    __finite, @function
-	.machine    power7
-ENTRY (__finite, 4)
-	CALL_MCOUNT 0
-	lfd     fp0,.LC0@toc(r2)
-	ftdiv   cr7,fp1,fp0
-	li	r3,1
-	bflr    30
-
-	/* If we are here, we either have +/-INF,
-	NaN or denormal.  */
-
-	stfd    fp1,-16(r1)   /* Transfer FP to GPR's.  */
-	ori	2,2,0	      /* Force a new dispatch group.  */
-	lhz     r4,-16+HISHORT(r1)  /* Fetch the upper 16 bits of the FP value
-				    (biased exponent and sign bit).  */
-	clrlwi  r4,r4,17      /* r4 = abs(r4).  */
-	cmpwi   cr7,r4,0x7ff0 /* r4 == 0x7ff0?  */
-	bltlr   cr7	      /* LT means finite, other non-finite.  */
-	li      r3,0
-	blr
-	END (__finite)
-
-hidden_def (__finite)
-weak_alias (__finite, finite)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__finite, __finitef)
-hidden_def (__finitef)
-weak_alias (__finitef, finitef)
-
-#if IS_IN (libm)
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
-compat_symbol (libm, __finite, __finitel, GLIBC_2_0)
-compat_symbol (libm, finite, finitel, GLIBC_2_0)
-# endif
-#else
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
-compat_symbol (libc, finite, finitel, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_finitef.S b/sysdeps/powerpc/powerpc64/power7/fpu/s_finitef.S
deleted file mode 100644
index 54bd94176d..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_finitef.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_finite.S.  */
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S
deleted file mode 100644
index f5316e898f..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/* isfinite().  PowerPC64/POWER8 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#define MFVSRD_R3_V1  .long 0x7c230066     /* mfvsrd  r3,vs1  */
-
-/* int [r3] __finite ([fp1] x)  */
-
-ENTRY_TOCLESS (__finite, 4)
-	CALL_MCOUNT 0
-	MFVSRD_R3_V1
-	lis     r9,0x8010
-	clrldi  r3,r3,1       /* r3 = r3 & 0x8000000000000000  */
-	rldicr  r9,r9,32,31   /* r9 = (r9 << 32) & 0xffffffff  */
-	add     r3,r3,r9
-	rldicl  r3,r3,1,63
-	blr
-END (__finite)
-
-hidden_def (__finite)
-weak_alias (__finite, finite)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__finite, __finitef)
-hidden_def (__finitef)
-weak_alias (__finitef, finitef)
-
-#if IS_IN (libm)
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
-compat_symbol (libm, __finite, __finitel, GLIBC_2_0)
-compat_symbol (libm, finite, finitel, GLIBC_2_0)
-# endif
-#else
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
-compat_symbol (libc, finite, finitel, GLIBC_2_0);
-# endif
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_finitef.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_finitef.S
deleted file mode 100644
index 54bd94176d..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_finitef.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_finite.S.  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 18/28] powerpc: refactor powerpc64 lrint/lrintf/llrint/llrintf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (16 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 17/28] powerpc: Remove optimized finite Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-13 19:30   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 19/28] powerpc: Refactor powerpc32 lrint/lrintf/llrint/llrintf Adhemerval Zanella
                   ` (9 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc llrint{f} implementations on
the generic sysdeps/powerpc/fpu/s_llrint{f}.

The IFUNC support is also moved only to powerpc64 only, since for
powerpc64le generic implementation resulting in optimized code.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
	(libm-sysdep_routines): Add s_llrint-power8, s_llrint-power6x, and
	s_llrint-ppc64.
	(CFLAGS-s_llrint-power8.c, CFLAGS-s_llrint-power6x.c): New rule.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power6x.c: New
	file.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power8.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_lrint.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_lrint.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrintf.c: ... here.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_lrint.c: New file.
	* sysdeps/powerpc/powerpc64/fpu/Makefile: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove s_llrint-* objects.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power6x.S: Remove
	file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-ppc64.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llrint.c: New file.
	* sysdeps/powerpc/powerpc64/fpu/s_llrintf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_lrint.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_lrintf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Remove file.
	* sysdeps/powerpc/powerpc64/fpu/s_llrintf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_lrint.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: Likewise.
---
 .../powerpc64/be/fpu/multiarch/Makefile       |  7 ++-
 .../be/fpu/multiarch/s_llrint-power6x.c       |  2 +
 .../be/fpu/multiarch/s_llrint-power8.c        |  2 +
 .../be/fpu/multiarch/s_llrint-ppc64.c         |  2 +
 .../{ => be}/fpu/multiarch/s_llrint.c         |  0
 .../{ => be}/fpu/multiarch/s_llrintf.c        |  0
 .../{ => be}/fpu/multiarch/s_lrint.c          |  0
 sysdeps/powerpc/powerpc64/fpu/Makefile        |  5 ++
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  3 +-
 .../fpu/multiarch/s_llrint-power6x.S          | 30 ----------
 .../powerpc64/fpu/multiarch/s_llrint-power8.S | 30 ----------
 .../powerpc64/fpu/multiarch/s_llrint-ppc64.S  | 30 ----------
 sysdeps/powerpc/powerpc64/fpu/s_llrint.S      | 45 ---------------
 sysdeps/powerpc/powerpc64/fpu/s_llrint.c      | 55 +++++++++++++++++++
 sysdeps/powerpc/powerpc64/fpu/s_llrintf.S     |  1 -
 sysdeps/powerpc/powerpc64/fpu/s_llrintf.c     |  1 +
 sysdeps/powerpc/powerpc64/fpu/s_lrint.S       |  1 -
 sysdeps/powerpc/powerpc64/fpu/s_lrint.c       |  1 +
 sysdeps/powerpc/powerpc64/fpu/s_lrintf.c      |  1 +
 .../powerpc/powerpc64/power6x/fpu/s_llrint.S  | 42 --------------
 .../powerpc/powerpc64/power8/fpu/s_llrint.S   | 43 ---------------
 21 files changed, 76 insertions(+), 225 deletions(-)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power6x.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power8.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llrint.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llrintf.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_lrint.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/Makefile
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power6x.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrint.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrint.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintf.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lrint.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lrint.c
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lrintf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S

diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index 53e600f5f6..febda6dbb3 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -14,7 +14,10 @@ libm-sysdep_routines += s_ceil-power5+ \
 			s_trunc-power5+ \
 			s_trunc-ppc64 \
 			s_truncf-power5+ \
-			s_truncf-ppc64
+			s_truncf-ppc64 \
+			s_llrint-power8 \
+			s_llrint-power6x \
+			s_llrint-ppc64
 
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
@@ -24,4 +27,6 @@ CFLAGS-s_round-power5+.c = -mcpu=power5+
 CFLAGS-s_roundf-power5+.c = -mcpu=power5+
 CFLAGS-s_trunc-power5+.c = -mcpu=power5+
 CFLAGS-s_truncf-power5+.c = -mcpu=power5+
+CFLAGS-s_llrint-power8.c += -mcpu=power8
+CFLAGS-s_llrint-power6x.c += -mcpu=power6x
 endif
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power6x.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power6x.c
new file mode 100644
index 0000000000..ee139b4045
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power6x.c
@@ -0,0 +1,2 @@
+#define __llrint __llrint_power6x
+#include <sysdeps/powerpc/powerpc64/fpu/s_llrint.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power8.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power8.c
new file mode 100644
index 0000000000..0f5cbff69a
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-power8.c
@@ -0,0 +1,2 @@
+#define __llrint __llrint_power8
+#include <sysdeps/powerpc/powerpc64/fpu/s_llrint.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-ppc64.c
new file mode 100644
index 0000000000..40f212716b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint-ppc64.c
@@ -0,0 +1,2 @@
+#define __llrint  __llrint_ppc64
+#include <sysdeps/powerpc/powerpc64/fpu/s_llrint.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrint.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrintf.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llrintf.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_lrint.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_lrint.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_lrint.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_lrint.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/Makefile b/sysdeps/powerpc/powerpc64/fpu/Makefile
new file mode 100644
index 0000000000..6988a1d396
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/Makefile
@@ -0,0 +1,5 @@
+ifeq ($(subdir),math)
+# lrintf and llrintf are aliased to llrint, so suppress compiler builtins to
+# avoid mismatched signatures.
+CFLAGS-s_llrint.c += -fno-builtin-lrintf -fno-builtin-llrintf
+endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 4aa7fd6295..fec878bb9d 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -8,12 +8,11 @@ sysdep_calls := s_modf-power5+ s_modf-ppc64 \
 sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_llround-power6x \
 			s_llround-power5+ s_llround-ppc64 \
-			s_llrint-power6x s_llrint-ppc64 \
 			s_logb-power7 s_logbf-power7 \
 			s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
 			s_logbl-ppc64 e_hypot-ppc64 \
 			e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
-			s_llrint-power8 s_llround-power8 s_llroundf-ppc64 \
+			s_llround-power8 s_llroundf-ppc64 \
 			e_expf-power8 e_expf-ppc64 \
 			$(sysdep_calls:s_%=m_%)
 
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power6x.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power6x.S
deleted file mode 100644
index 19f9dd2d80..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power6x.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Round double to long int.  PowerPC64/POWER6X default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llrint __llrint_power6x
-
-#include <sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S
deleted file mode 100644
index 93310e8662..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Round double to long int.  PowerPC64/POWER6X default version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llrint __llrint_power8
-
-#include <sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-ppc64.S
deleted file mode 100644
index 2811def336..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-ppc64.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Round double to long int.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llrint __llrint_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_llrint.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S
deleted file mode 100644
index 2e0d4dfdd0..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Round double to long int.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* long long int[r3] __llrint (double x[fp1])  */
-ENTRY_TOCLESS (__llrint)
-	CALL_MCOUNT 0
-	fctid	fp13,fp1
-	stfd	fp13,-16(r1)
-	nop	/* Insure the following load is in a different dispatch group */
-	nop	/* to avoid pipe stall on POWER4&5.  */
-	nop
-	ld	r3,-16(r1)
-	blr
-	END (__llrint)
-
-strong_alias (__llrint, __lrint)
-libm_alias_double (__llrint, llrint)
-libm_alias_double (__lrint, lrint)
-/* The double version also works for single-precision as both float and
-   double parameters are passed in 64bit FPRs and both versions are expected
-   to return [long] long type.  */
-strong_alias (__llrint, __llrintf)
-libm_alias_float (__llrint, llrint)
-strong_alias (__lrint, __lrintf)
-libm_alias_float (__lrint, lrint)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrint.c b/sysdeps/powerpc/powerpc64/fpu/s_llrint.c
new file mode 100644
index 0000000000..968b70b79d
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_llrint.c
@@ -0,0 +1,55 @@
+/* Round to nearest integer.  PowerPC64 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#define lrint __redirect_lrint
+#define lrintf __redirect_lrintf
+#define llrintf __redirect_llrintf
+#define __lrint __redirect___lrint
+#define __lrintf __redirect___lrintf
+#define __llrintf __redirect___llrintf
+#include <math.h>
+#undef lrint
+#undef lrintf
+#undef llrintf
+#undef __lrint
+#undef __lrintf
+#undef __llrintf
+#include <libm-alias-float.h>
+#include <libm-alias-double.h>
+
+long long int
+__llrint (double x)
+{
+  long int ret;
+  __asm__ ("fctid %0, %1" : "=d" (ret) : "d" (x));
+  return ret;
+}
+#ifndef __llrint
+strong_alias (__llrint, __lrint)
+libm_alias_double (__llrint, llrint)
+libm_alias_double (__lrint, lrint)
+
+/* The double version also works for single-precision as both float and
+   double parameters are passed in 64bit FPRs and both versions are expected
+   to return [long] long type.  */
+strong_alias (__llrint, __llrintf)
+libm_alias_float (__llrint, llrint)
+strong_alias (__lrint, __lrintf)
+libm_alias_float (__lrint, lrint)
+#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S
deleted file mode 100644
index ba7752311d..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __llrintf is in s_llrint.S.  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.c b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.c
new file mode 100644
index 0000000000..fd8ce33620
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.c
@@ -0,0 +1 @@
+/* llrintf is implemented at s_llrint.c  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lrint.S b/sysdeps/powerpc/powerpc64/fpu/s_lrint.S
deleted file mode 100644
index d3c2fff581..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_lrint.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __lrint is in s_llrint.c  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lrint.c b/sysdeps/powerpc/powerpc64/fpu/s_lrint.c
new file mode 100644
index 0000000000..4e48d8ca00
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_lrint.c
@@ -0,0 +1 @@
+/* lrint is implemented at s_llrint.c  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lrintf.c b/sysdeps/powerpc/powerpc64/fpu/s_lrintf.c
new file mode 100644
index 0000000000..3f0c570a91
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_lrintf.c
@@ -0,0 +1 @@
+/* lrintf is implemented at s_llrint.c  */
diff --git a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S
deleted file mode 100644
index edf3974c77..0000000000
--- a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Round double to long int.  POWER6x PowerPC64 version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-	.machine	"power6"
-/* long long int[r3] __llrint (double x[fp1])  */
-ENTRY_TOCLESS (__llrint)
-	CALL_MCOUNT 0
-	fctid	fp13,fp1
-	mftgpr  r3,fp13
-	blr
-	END (__llrint)
-
-strong_alias (__llrint, __lrint)
-libm_alias_double (__llrint, llrint)
-libm_alias_double (__lrint, lrint)
-/* The double version also works for single-precision as both float and
-   double parameters are passed in 64bit FPRs and both versions are expected
-   to return [long] long type.  */
-strong_alias (__llrint, __llrintf)
-libm_alias_float (__llrint, llrint)
-strong_alias (__lrint, __lrintf)
-libm_alias_float (__lrint, lrint)
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S
deleted file mode 100644
index dbd3ab89d6..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Round double to long int.  POWER8 PowerPC64 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-#define MFVSRD_R3_V1  .long 0x7c230066     /* mfvsrd  r3,vs1  */
-
-/* long long int[r3] __llrint (double x[fp1])  */
-ENTRY_TOCLESS (__llrint)
-	CALL_MCOUNT 0
-	fctid	fp1,fp1
-	MFVSRD_R3_V1
-	blr
-END (__llrint)
-
-strong_alias (__llrint, __lrint)
-libm_alias_double (__llrint, llrint)
-libm_alias_double (__lrint, lrint)
-/* The double version also works for single-precision as both float and
-   double parameters are passed in 64bit FPRs and both versions are expected
-   to return [long] long type.  */
-strong_alias (__llrint, __llrintf)
-libm_alias_float (__llrint, llrint)
-strong_alias (__lrint, __lrintf)
-libm_alias_float (__lrint, lrint)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 19/28] powerpc: Refactor powerpc32 lrint/lrintf/llrint/llrintf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (17 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 18/28] powerpc: refactor powerpc64 lrint/lrintf/llrint/llrintf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-14 18:34   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 20/28] powerpc: Refactor powerpc64 lround/lroundf/llround/llroundf Adhemerval Zanella
                   ` (8 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc llrint{f} implementations on
the generic sysdeps/powerpc/powerpc32/fpu/s_llrint{f}.  The only missing
optimization is the power6x one which I could not make GCC generates
mftgpr for 32 bits output.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/s_lrintf.S: Remove file.
	* sysdeps/powerpc/powerpc64/fpu/s_lrintf.c: Move to ...
	* sysdeps/powerpc/fpu/s_lrintf.c: ... here.
	* sysdeps/powerpc/powerpc32/fpu/Makefile
	[$(subdir) == math] (CFLAGS-s_lrint.c): New rule.
	* sysdeps/powerpc/powerpc32/fpu/s_llrint.c (__llrint): Add power4
	optimization.
	* sysdeps/powerpc/powerpc32/fpu/s_llrintf.c (__llrintf): Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_lrint.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_lrint.c: New file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
	(CFLAGS-s_llrintf-power6.c, CFLAGS-s_llrintf-ppc32.c,
	CFLAGS-s_llrint-power6.c, CFLAGS-s_llrint-ppc32.c,
	CFLAGS-s_lrint-ppc32.c): New rule.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.S:
	Remove file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.c:
	New file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.c:
	Likewise.
---
 sysdeps/powerpc/fpu/s_lrintf.S                |  1 -
 .../powerpc/{powerpc64 => }/fpu/s_lrintf.c    |  0
 sysdeps/powerpc/powerpc32/fpu/Makefile        |  6 +++
 sysdeps/powerpc/powerpc32/fpu/s_llrint.c      |  9 +++++
 sysdeps/powerpc/powerpc32/fpu/s_llrintf.c     |  7 ++++
 sysdeps/powerpc/powerpc32/fpu/s_lrint.S       | 40 -------------------
 sysdeps/powerpc/powerpc32/fpu/s_lrint.c       | 40 +++++++++++++++++++
 .../powerpc32/power4/fpu/multiarch/Makefile   |  5 +++
 .../power4/fpu/multiarch/s_llrint-power6.S    | 31 --------------
 .../power4/fpu/multiarch/s_llrint-power6.c    |  2 +
 .../power4/fpu/multiarch/s_llrint-ppc32.S     | 31 --------------
 .../power4/fpu/multiarch/s_llrint-ppc32.c     |  2 +
 .../power4/fpu/multiarch/s_llrintf-power6.S   | 26 ------------
 .../power4/fpu/multiarch/s_llrintf-power6.c   |  2 +
 .../power4/fpu/multiarch/s_llrintf-ppc32.S    | 26 ------------
 .../power4/fpu/multiarch/s_llrintf-ppc32.c    |  2 +
 .../power4/fpu/multiarch/s_lrint-ppc32.S      | 31 --------------
 .../power4/fpu/multiarch/s_lrint-ppc32.c      |  2 +
 .../powerpc/powerpc32/power4/fpu/s_llrint.S   | 39 ------------------
 .../powerpc/powerpc32/power4/fpu/s_llrintf.S  | 39 ------------------
 .../powerpc/powerpc32/power6/fpu/s_llrint.S   | 39 ------------------
 .../powerpc/powerpc32/power6/fpu/s_llrintf.S  | 39 ------------------
 22 files changed, 77 insertions(+), 342 deletions(-)
 delete mode 100644 sysdeps/powerpc/fpu/s_lrintf.S
 rename sysdeps/powerpc/{powerpc64 => }/fpu/s_lrintf.c (100%)
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lrint.S
 create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lrint.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S

diff --git a/sysdeps/powerpc/fpu/s_lrintf.S b/sysdeps/powerpc/fpu/s_lrintf.S
deleted file mode 100644
index e24766535f..0000000000
--- a/sysdeps/powerpc/fpu/s_lrintf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __lrintf is in s_lrint.c  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lrintf.c b/sysdeps/powerpc/fpu/s_lrintf.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/s_lrintf.c
rename to sysdeps/powerpc/fpu/s_lrintf.c
diff --git a/sysdeps/powerpc/powerpc32/fpu/Makefile b/sysdeps/powerpc/powerpc32/fpu/Makefile
index e05073970d..c79b192f60 100644
--- a/sysdeps/powerpc/powerpc32/fpu/Makefile
+++ b/sysdeps/powerpc/powerpc32/fpu/Makefile
@@ -1,3 +1,9 @@
+ifeq ($(subdir),math)
+# lrint is aliased to lrintf, so suppress compiler builtins to
+# avoid mismatched signatures.
+CFLAGS-s_lrint.c += -fno-builtin-lrintf
+endif
+
 ifeq ($(subdir),misc)
 sysdep_routines += fprsave fprrest
 endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_llrint.c b/sysdeps/powerpc/powerpc32/fpu/s_llrint.c
index 7e91d606c2..42558efd46 100644
--- a/sysdeps/powerpc/powerpc32/fpu/s_llrint.c
+++ b/sysdeps/powerpc/powerpc32/fpu/s_llrint.c
@@ -26,6 +26,12 @@
 long long int
 __llrint (double x)
 {
+#ifdef _ARCH_PWR4
+  /* Assume powerpc64 instructions availability.  */
+  long long int ret;
+  __asm__ ("fctid %0, %1" : "=d" (ret) : "d" (x));
+  return ret;
+#else
   double rx = rint (x);
   if (HAVE_PPC_FCTIDZ || rx != x)
     return (long long int) rx;
@@ -53,5 +59,8 @@ __llrint (double x)
       else
 	return (long long int) (long int) rx << 32;
     }
+#endif
 }
+#ifndef __llrint
 libm_alias_double (__llrint, llrint)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c b/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c
index 021a86fada..b75655e2c1 100644
--- a/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c
+++ b/sysdeps/powerpc/powerpc32/fpu/s_llrintf.c
@@ -24,6 +24,12 @@
 long long int
 __llrintf (float x)
 {
+#ifdef _ARCH_PWR4
+  /* Assume powerpc64 instructions availability.  */
+  long long int ret;
+  __asm__ ("fctid %0, %1" : "=d" (ret) : "d" (x));
+  return ret;
+#else
   float rx = rintf (x);
   if (HAVE_PPC_FCTIDZ || rx != x)
     return (long long int) rx;
@@ -43,5 +49,6 @@ __llrintf (float x)
       mant <<= exponent - 23;
       return (long long int) ((i0 & 0x80000000) != 0 ? -mant : mant);
     }
+#endif
 }
 libm_alias_float (__llrint, llrint)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lrint.S b/sysdeps/powerpc/powerpc32/fpu/s_lrint.S
deleted file mode 100644
index fdad180116..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_lrint.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Round double to long int.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* long int[r3] __lrint (double x[fp1])  */
-ENTRY (__lrint)
-	stwu	r1,-16(r1)
-	fctiw	fp13,fp1
-	stfd	fp13,8(r1)
-	nop	/* Ensure the following load is in a different dispatch group */
-	nop	/* to avoid pipe stall on POWER4&5.  */
-	nop
-	lwz	r3,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__lrint)
-
-libm_alias_double (__lrint, lrint)
-
-strong_alias (__lrint, __lrintf)
-libm_alias_float (__lrint, lrint)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lrint.c b/sysdeps/powerpc/powerpc32/fpu/s_lrint.c
new file mode 100644
index 0000000000..21bdc5c063
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/s_lrint.c
@@ -0,0 +1,40 @@
+/* Round to nearest integer.  PowerPC32 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#define lrintf __redirect_lrintf
+#define __lrintf __redirect___lrintf
+#include <math.h>
+#undef lrintf
+#undef __lrintf
+#include <fenv_private.h>
+#include <libm-alias-double.h>
+#include <libm-alias-float.h>
+
+long int
+__lrint (double x)
+{
+  long long int ret;
+  __asm__ ("fctiw %0, %1" : "=d" (ret) : "d" (x));
+  return ret;
+}
+#ifndef __lrint
+libm_alias_double (__lrint, lrint)
+strong_alias (__lrint, __lrintf)
+libm_alias_float (__lrint, lrint)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index 51b13fe33a..d33d403a1b 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -18,6 +18,11 @@ libm-sysdep_routines += s_llrintf-power6 s_llrintf-ppc32 s_llrint-power6 \
 			s_logbf-power7 s_logbf-ppc32 e_hypot-power7 \
 			e_hypot-ppc32 e_hypotf-power7 e_hypotf-ppc32
 
+CFLAGS-s_llrintf-power6.c += -mcpu=power6
+CFLAGS-s_llrintf-ppc32.c += -mcpu=power4
+CFLAGS-s_llrint-power6.c += -mcpu=power6
+CFLAGS-s_llrint-ppc32.c += -mcpu=power4
+CFLAGS-s_lrint-ppc32.c += -mcpu=power4
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
 CFLAGS-s_modf-power5+.c = -mcpu=power5+
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.S
deleted file mode 100644
index 253a12bf72..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Round double to long int.  PowerPC32/Power6.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llrint __llrint_power6
-
-#include <sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.c
new file mode 100644
index 0000000000..328e11844f
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.c
@@ -0,0 +1,2 @@
+#define __llrint __llrint_power6
+#include <sysdeps/powerpc/powerpc32/fpu/s_llrint.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.S
deleted file mode 100644
index e7bf6760c1..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* llrint function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llrint __llrint_ppc32
-
-#include <sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.c
new file mode 100644
index 0000000000..8f192ab990
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.c
@@ -0,0 +1,2 @@
+#define __llrint __llrint_ppc32
+#include <sysdeps/powerpc/powerpc32/fpu/s_llrint.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.S
deleted file mode 100644
index c6b7769457..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Round float to long int.  PowerPC32/POWER6 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __llrintf __llrintf_power6
-
-#include <sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.c
new file mode 100644
index 0000000000..5b1a5a8cf0
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-power6.c
@@ -0,0 +1,2 @@
+#define __llrintf __llrintf_power6
+#include <sysdeps/powerpc/powerpc32/fpu/s_llrintf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.S
deleted file mode 100644
index c592b31aff..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/* llrintf function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-
-#define __llrintf __llrintf_ppc32
-
-#include <sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.c
new file mode 100644
index 0000000000..061962b84d
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf-ppc32.c
@@ -0,0 +1,2 @@
+#define __llrintf __llrintf_ppc32
+#include <sysdeps/powerpc/powerpc32/fpu/s_llrintf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.S
deleted file mode 100644
index 617a9a7b8d..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Round double to long int.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __lrint __lrint_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_lrint.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.c
new file mode 100644
index 0000000000..ce2764b61b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint-ppc32.c
@@ -0,0 +1,2 @@
+#define __lrint __lrint_ppc32
+#include <sysdeps/powerpc/powerpc32/fpu/s_lrint.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S b/sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S
deleted file mode 100644
index 3fdb5c3fe3..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Round double to long int.  PowerPC32 on PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-/* long long int[r3, r4] __llrint (double x[fp1])  */
-ENTRY (__llrint)
-	CALL_MCOUNT
-	stwu	r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	fctid	fp13,fp1
-	stfd	fp13,8(r1)
-	nop	/* Insure the following load is in a different dispatch group */
-	nop	/* to avoid pipe stall on POWER4&5.  */
-	nop
-	lwz	r3,8+HIWORD(r1)
-	lwz	r4,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__llrint)
-
-libm_alias_double (__llrint, llrint)
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S b/sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S
deleted file mode 100644
index 3a6364241e..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Round float to long int.  PowerPC32 on PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-/* long long int[r3, r4] __llrintf (float x[fp1])  */
-ENTRY (__llrintf)
-	CALL_MCOUNT
-	stwu	r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	fctid	fp13,fp1
-	stfd	fp13,8(r1)
-	nop	/* Insure the following load is in a different dispatch group */
-	nop	/* to avoid pipe stall on POWER4&5.  */
-	nop
-	lwz	r3,8+HIWORD(r1)
-	lwz	r4,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__llrintf)
-
-libm_alias_float (__llrint, llrint)
-
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S
deleted file mode 100644
index e8134f7451..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Round double to long int.  PowerPC32 on PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-/* long long int[r3, r4] __llrint (double x[fp1])  */
-ENTRY (__llrint)
-	CALL_MCOUNT
-	stwu	r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	fctid	fp13,fp1
-	stfd	fp13,8(r1)
-/* Insure the following load is in a different dispatch group by
-   inserting "group ending nop".  */
-	ori	r1,r1,0
-	lwz	r3,8+HIWORD(r1)
-	lwz	r4,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__llrint)
-
-libm_alias_double (__llrint, llrint)
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S
deleted file mode 100644
index b4d013f7a3..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Round float to long int.  PowerPC32 on PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-/* long long int[r3, r4] __llrintf (float x[fp1])  */
-ENTRY (__llrintf)
-	CALL_MCOUNT
-	stwu	r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	fctid	fp13,fp1
-	stfd	fp13,8(r1)
-/* Insure the following load is in a different dispatch group by
-   inserting "group ending nop".  */
-	ori	r1,r1,0
-	lwz	r3,8+HIWORD(r1)
-	lwz	r4,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__llrintf)
-
-libm_alias_float (__llrint, llrint)
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 20/28] powerpc: Refactor powerpc64 lround/lroundf/llround/llroundf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (18 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 19/28] powerpc: Refactor powerpc32 lrint/lrintf/llrint/llrintf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-13 19:30   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf Adhemerval Zanella
                   ` (7 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc {l}lround{f} implementations
on the generic sysdeps/powerpc/fpu/s_{l}lround{f}.c.

The IFUNC support is also moved only to powerpc64 only, since for
powerpc64le generic implementation resulting in optimized code.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
	(libm-sysdep_routines): Add s_llround-power8, s_llround-power6x,
	s_llround-power5+, s_llround-ppc64, and s_llroundf-ppc64.
	(CFLAGS-s_llround-power8.c, CFLAGS-s_llround-power6x.c,
	CFLAGS-s_llround-power5+.c): New rule.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power5+.c:
	New file.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power6x.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power8.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf-ppc64.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_lround.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_lround.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/Makefile
	[$(subdir) == math] (CFLAGS-s_llround.c): New rule.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove s_llround-* objects.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power5+.S: Remove
	file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power6x.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power8.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-ppc64.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf-ppc64.S:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llroundf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_lround.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_lroundf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llround.c: New file.
	* sysdeps/powerpc/powerpc64/fpu/s_llroundf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_lround.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_lroundf.c: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_llroundf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llroundf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llroundf.S: Likewise.
---
 .../powerpc64/be/fpu/multiarch/Makefile       | 12 ++-
 .../be/fpu/multiarch/s_llround-power5+.c      |  2 +
 .../be/fpu/multiarch/s_llround-power6x.c      |  2 +
 .../be/fpu/multiarch/s_llround-power8.c       |  2 +
 .../be/fpu/multiarch/s_llround-ppc64.c        |  2 +
 .../{ => be}/fpu/multiarch/s_llround.c        |  0
 .../be/fpu/multiarch/s_llroundf-ppc64.c       |  2 +
 .../{ => be}/fpu/multiarch/s_llroundf.c       |  0
 .../{ => be}/fpu/multiarch/s_lround.c         |  0
 sysdeps/powerpc/powerpc64/fpu/Makefile        |  2 +
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  5 +-
 .../fpu/multiarch/s_llround-power5+.S         | 31 -------
 .../fpu/multiarch/s_llround-power6x.S         | 31 -------
 .../fpu/multiarch/s_llround-power8.S          | 30 -------
 .../powerpc64/fpu/multiarch/s_llround-ppc64.S | 27 ------
 .../fpu/multiarch/s_llroundf-ppc64.S          | 31 -------
 sysdeps/powerpc/powerpc64/fpu/s_llround.S     | 86 ------------------
 sysdeps/powerpc/powerpc64/fpu/s_llround.c     | 83 +++++++++++++++++
 sysdeps/powerpc/powerpc64/fpu/s_llroundf.S    | 89 -------------------
 sysdeps/powerpc/powerpc64/fpu/s_llroundf.c    | 83 +++++++++++++++++
 sysdeps/powerpc/powerpc64/fpu/s_lround.S      |  1 -
 sysdeps/powerpc/powerpc64/fpu/s_lround.c      |  1 +
 sysdeps/powerpc/powerpc64/fpu/s_lroundf.S     |  1 -
 sysdeps/powerpc/powerpc64/fpu/s_lroundf.c     |  1 +
 .../powerpc/powerpc64/power5+/fpu/s_llround.S | 56 ------------
 .../powerpc64/power5+/fpu/s_llroundf.S        |  1 -
 .../powerpc/powerpc64/power6x/fpu/s_llround.S | 52 -----------
 .../powerpc64/power6x/fpu/s_llroundf.S        |  1 -
 .../powerpc/powerpc64/power8/fpu/s_llround.S  | 46 ----------
 .../powerpc/powerpc64/power8/fpu/s_llroundf.S |  1 -
 30 files changed, 190 insertions(+), 491 deletions(-)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power5+.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power6x.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power8.c
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llround.c (100%)
 create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf-ppc64.c
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_llroundf.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_lround.c (100%)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power5+.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power6x.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf-ppc64.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llround.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llround.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llroundf.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llroundf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lround.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lround.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lroundf.S
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lroundf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power6x/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_llroundf.S

diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index febda6dbb3..9917cd15d5 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -17,7 +17,12 @@ libm-sysdep_routines += s_ceil-power5+ \
 			s_truncf-ppc64 \
 			s_llrint-power8 \
 			s_llrint-power6x \
-			s_llrint-ppc64
+			s_llrint-ppc64 \
+			s_llround-power8 \
+			s_llround-power6x \
+			s_llround-power5+ \
+			s_llround-ppc64 \
+			s_llroundf-ppc64
 
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
@@ -27,6 +32,7 @@ CFLAGS-s_round-power5+.c = -mcpu=power5+
 CFLAGS-s_roundf-power5+.c = -mcpu=power5+
 CFLAGS-s_trunc-power5+.c = -mcpu=power5+
 CFLAGS-s_truncf-power5+.c = -mcpu=power5+
-CFLAGS-s_llrint-power8.c += -mcpu=power8
-CFLAGS-s_llrint-power6x.c += -mcpu=power6x
+CFLAGS-s_llround-power8.c += -mcpu=power8
+CFLAGS-s_llround-power6x.c += -mcpu=power6x
+CFLAGS-s_llround-power5+.c += -mcpu=power5+
 endif
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power5+.c
new file mode 100644
index 0000000000..182132b825
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power5+.c
@@ -0,0 +1,2 @@
+#define __llround __llround_power5plus
+#include <sysdeps/powerpc/powerpc64/fpu/s_llround.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power6x.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power6x.c
new file mode 100644
index 0000000000..542319d56b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power6x.c
@@ -0,0 +1,2 @@
+#define __llround __llround_power6x
+#include <sysdeps/powerpc/powerpc64/fpu/s_llround.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power8.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power8.c
new file mode 100644
index 0000000000..5d2b3b8d44
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-power8.c
@@ -0,0 +1,2 @@
+#define __llround __llround_power8
+#include <sysdeps/powerpc/powerpc64/fpu/s_llround.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-ppc64.c
new file mode 100644
index 0000000000..8793bd7814
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround-ppc64.c
@@ -0,0 +1,2 @@
+#define __llround __llround_ppc64
+#include <sysdeps/powerpc/powerpc64/fpu/s_llround.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llround.c
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf-ppc64.c
new file mode 100644
index 0000000000..dba4c654db
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf-ppc64.c
@@ -0,0 +1,2 @@
+#define __llroundf __llroundf_ppc64
+#include <sysdeps/powerpc/powerpc64/fpu/s_llroundf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_llroundf.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_lround.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_lround.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_lround.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_lround.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/Makefile b/sysdeps/powerpc/powerpc64/fpu/Makefile
index 6988a1d396..05075c2a75 100644
--- a/sysdeps/powerpc/powerpc64/fpu/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/Makefile
@@ -2,4 +2,6 @@ ifeq ($(subdir),math)
 # lrintf and llrintf are aliased to llrint, so suppress compiler builtins to
 # avoid mismatched signatures.
 CFLAGS-s_llrint.c += -fno-builtin-lrintf -fno-builtin-llrintf
+# Same as before but for lroundf and llroundf
+CFLAGS-s_llround.c += -fno-builtin-lroundf -fno-builtin-llroundf
 endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index fec878bb9d..48cf8dca3b 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -6,13 +6,10 @@ sysdep_calls := s_modf-power5+ s_modf-ppc64 \
 		s_modff-power5+ s_modff-ppc64
 
 sysdep_routines += $(sysdep_calls)
-libm-sysdep_routines += s_llround-power6x \
-			s_llround-power5+ s_llround-ppc64 \
-			s_logb-power7 s_logbf-power7 \
+libm-sysdep_routines += s_logb-power7 s_logbf-power7 \
 			s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
 			s_logbl-ppc64 e_hypot-ppc64 \
 			e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
-			s_llround-power8 s_llroundf-ppc64 \
 			e_expf-power8 e_expf-ppc64 \
 			$(sysdep_calls:s_%=m_%)
 
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power5+.S
deleted file mode 100644
index 59ec9d8dec..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power5+.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* llround().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llround __llround_power5plus
-#define __lround __lround_power5plus
-
-#include <sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power6x.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power6x.S
deleted file mode 100644
index 127c1e9959..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power6x.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* llround().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __llround __llround_power6x
-#define __lround __lround_power6x
-
-#include <sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power8.S
deleted file mode 100644
index 4e36482f0a..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-power8.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* llround().  PowerPC64 default version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __llround __llround_power8
-
-#include <sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-ppc64.S
deleted file mode 100644
index fe01c33002..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround-ppc64.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/* llround().  PowerPC64 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llround __llround_ppc64
-#define __lround __lround_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_llround.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf-ppc64.S
deleted file mode 100644
index c62bb92e13..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf-ppc64.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* llroundf().  PowerPC64 default version.
-   Copyright (C) 2017-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llroundf __llroundf_ppc64
-#define __lroundf __lroundf_ppc64
-
-#include <sysdeps/powerpc/powerpc64/fpu/s_llroundf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/fpu/s_llround.S
deleted file mode 100644
index 7180779921..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_llround.S
+++ /dev/null
@@ -1,86 +0,0 @@
-/* llround function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
-
-	.section	".toc","aw"
-.LC0:	/* 2^52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-.LC1:	/* 0.5 */
-	.tc FD_3fe00000_0[TC],0x3fe0000000000000
-	.section	".text"
-
-/* long long [r3] llround (double x [fp1])
-   IEEE 1003.1 llround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "round to Nearest" mode. Instead we set
-   "round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.
-
-   It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
-   because adding +-0.5 in this case will cause an erroneous shift,
-   carry and round.  We simply return 0 if 0.5 > x > -0.5.  Likewise
-   if x is and odd number between +-(2^52 and 2^53-1) a shift and
-   carry will erroneously round if biased with +-0.5.  Therefore if x
-   is greater/less than +-2^52 we don't need to bias the number with
-   +-0.5.  */
-
-ENTRY (__llround)
-	CALL_MCOUNT 0
-	lfd	fp9,.LC0@toc(2)	/* Load 2^52 into fpr9.  */
-	lfd	fp10,.LC1@toc(2)/* Load 0.5 into fpr10.  */
-	fabs	fp2,fp1		/* Get the absolute value of x.  */
-	fsub	fp12,fp10,fp10	/* Compute 0.0 into fp12.  */
-	fcmpu	cr6,fp2,fp10	/* if |x| < 0.5  */
-	fcmpu	cr7,fp2,fp9	/* if |x| >= 2^52  */
-	fcmpu	cr1,fp1,fp12	/* x is negative? x < 0.0  */
-	blt-	cr6,.Lretzero	/* 0.5 > x < -0.5 so just return 0.  */
-	bge-	cr7,.Lnobias	/* 2^52 > x < -2^52 just convert with no bias.  */
-	/* Test whether an integer to avoid spurious "inexact".  */
-	fadd	fp3,fp2,fp9
-	fsub	fp3,fp3,fp9
-	fcmpu	cr5,fp2,fp3
-	beq	cr5,.Lnobias
-	fadd	fp3,fp2,fp10	/* |x|+=0.5 bias to prepare to round.  */
-	bge	cr1,.Lconvert	/* x is positive so don't negate x.  */
-	fnabs	fp3,fp3		/* -(|x|+=0.5)  */
-.Lconvert:
-	fctidz	fp4,fp3		/* Convert to Integer double word round toward 0.  */
-	stfd	fp4,-16(r1)
-	nop
-	nop
-	nop
-	ld	r3,-16(r1)	/* Load return as integer.  */
-.Lout:
-	blr
-.Lretzero:			/* 0.5 > x > -0.5  */
-	li	r3,0		/* return 0.  */
-	b	.Lout
-.Lnobias:
-	fmr	fp3,fp1
-	b	.Lconvert
-	END (__llround)
-
-strong_alias (__llround, __lround)
-libm_alias_double (__llround, llround)
-libm_alias_double (__lround, lround)
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llround.c b/sysdeps/powerpc/powerpc64/fpu/s_llround.c
new file mode 100644
index 0000000000..6aa8fea195
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_llround.c
@@ -0,0 +1,83 @@
+/* Round to nearest integer.  PowerPC64 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#define lround __redirect_lround
+#define __lround __redirect___lround
+#include <math.h>
+#undef lround
+#undef __lround
+#include <libm-alias-double.h>
+#include <math-barriers.h>
+
+long long int
+__llround (double x)
+{
+#ifdef _ARCH_PWR5X
+  double r = __builtin_round (x);
+  /* Prevent gcc from calling llround directly when compiled with
+     -fno-math-errno by inserting a barrier.  */
+  math_opt_barrier (r);
+  return r;
+#else
+  /* IEEE 1003.1 llround function.  IEEE specifies "round to the nearest
+     integer value, rounding halfway cases away from zero, regardless of
+     the current rounding mode."  However PowerPC Architecture defines
+     "round to Nearest" as "Choose the best approximation. In case of a
+     tie, choose the one that is even (least significant bit o).".
+     So we can't use the PowerPC "round to Nearest" mode. Instead we set
+     "round toward Zero" mode and round by adding +-0.5 before rounding
+     to the integer value.
+
+     It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
+     because adding +-0.5 in this case will cause an erroneous shift,
+     carry and round.  We simply return 0 if 0.5 > x > -0.5.  Likewise
+     if x is and odd number between +-(2^52 and 2^53-1) a shift and
+     carry will erroneously round if biased with +-0.5.  Therefore if x
+     is greater/less than +-2^52 we don't need to bias the number with
+     +-0.5.  */
+
+  double ax = fabs (x);
+
+  if (ax < 0.5)
+    return 0;
+
+  if (ax < 0x1p+52)
+    {
+      /* Test whether an integer to avoid spurious "inexact".  */
+      double t = ax + 0x1p+52;
+      t = t - 0x1p+52;
+      if (ax != t)
+	{
+	  ax = ax + 0.5;
+	  if (x < 0.0)
+	    ax = -fabs (ax);
+	  x = ax;
+	}
+    }
+
+  long int ret;
+  __asm__ ("fctidz %0, %1" : "=d" (ret) : "d" (x));
+  return ret;
+#endif
+}
+#ifndef __llround
+strong_alias (__llround, __lround)
+libm_alias_double (__llround, llround)
+libm_alias_double (__lround, lround)
+#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S
deleted file mode 100644
index b8afebc7dc..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S
+++ /dev/null
@@ -1,89 +0,0 @@
-/* llroundf function.  PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <libm-alias-float.h>
-
-	.section	".toc","aw"
-.LC0:	/* 2^23 */
-	.tc FD_41600000_0[TC],0x4160000000000000
-.LC1:	/* 0.5 */
-	.tc FD_3fe00000_0[TC],0x3fe0000000000000
-.LC2:	/* 2^52 */
-	.tc FD_43300000_0[TC],0x4330000000000000
-	.section	".text"
-
-/* long long [r3] llroundf (float x [fp1])
-   IEEE 1003.1 llroundf function.  IEEE specifies "roundf to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "roundf to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "round to Nearest" mode. Instead we set
-   "round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.
-
-   It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
-   because adding +-0.5 in this case will cause an erroneous shift,
-   carry and round.  We simply return 0 if 0.5 > x > -0.5.  Likewise
-   if x is and odd number between +-(2^23 and 2^24-1) a shift and
-   carry will erroneously round if biased with +-0.5.  Therefore if x
-   is greater/less than +-2^23 we don't need to bias the number with
-   +-0.5.  */
-
-ENTRY (__llroundf)
-	CALL_MCOUNT 0
-	lfd	fp9,.LC0@toc(2)	/* Load 2^23 into fpr9.  */
-	lfd	fp10,.LC1@toc(2)/* Load 0.5 into fpr10.  */
-	lfd	fp11,.LC2@toc(2)	/* Load 2^52 into fpr11.  */
-	fabs	fp2,fp1		/* Get the absolute value of x.  */
-	fsub	fp12,fp10,fp10	/* Compute 0.0 into fp12.  */
-	fcmpu	cr6,fp2,fp10	/* if |x| < 0.5  */
-	fcmpu	cr7,fp2,fp9	/* if |x| >= 2^23  */
-	fcmpu	cr1,fp1,fp12	/* x is negative? x < 0.0  */
-	blt-	cr6,.Lretzero	/* 0.5 > x < -0.5 so just return 0.  */
-	bge-	cr7,.Lnobias	/* 2^23 > x < -2^23 just convert with no bias.  */
-	/* Test whether an integer to avoid spurious "inexact".  */
-	fadd	fp3,fp2,fp11
-	fsub	fp3,fp3,fp11
-	fcmpu	cr5,fp2,fp3
-	beq	cr5,.Lnobias
-	fadd	fp3,fp2,fp10	/* |x|+=0.5 bias to prepare to round.  */
-	bge	cr1,.Lconvert	/* x is positive so don't negate x.  */
-	fnabs	fp3,fp3		/* -(|x|+=0.5)  */
-.Lconvert:
-	fctidz	fp4,fp3		/* Convert to Integer double word round toward 0.  */
-	stfd	fp4,-16(r1)
-	nop
-	nop
-	nop
-	ld	r3,-16(r1)	/* Load return as integer.  */
-.Lout:
-	blr
-.Lretzero:			/* 0.5 > x > -0.5  */
-	li	r3,0		/* return 0.  */
-	b	.Lout
-.Lnobias:
-	fmr	fp3,fp1
-	b	.Lconvert
-	END (__llroundf)
-
-strong_alias (__llroundf, __lroundf)
-libm_alias_float (__llround, llround)
-libm_alias_float (__lround, lround)
-
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.c b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.c
new file mode 100644
index 0000000000..160c00ed6f
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.c
@@ -0,0 +1,83 @@
+/* Round to nearest integer.  PowerPC64 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#define lroundf __redirect_llround
+#define __lroundf __redirect___lround
+#include <math.h>
+#undef lroundf
+#undef __lroundf
+#include <libm-alias-float.h>
+#include <math-barriers.h>
+
+long long int
+__llroundf (float x)
+{
+#ifdef _ARCH_PWR5X
+  double r = __builtin_round (x);
+  /* Prevent gcc from calling llround directly when compiled with
+     -fno-math-errno by inserting a barrier.  */
+  math_opt_barrier (r);
+  return r;
+#else
+   /* IEEE 1003.1 llroundf function.  IEEE specifies "roundf to the nearest
+      integer value, rounding halfway cases away from zero, regardless of
+      the current rounding mode."  However PowerPC Architecture defines
+      "roundf to Nearest" as "Choose the best approximation. In case of a
+      tie, choose the one that is even (least significant bit o).".
+      So we can't use the PowerPC "round to Nearest" mode. Instead we set
+      "round toward Zero" mode and round by adding +-0.5 before rounding
+      to the integer value.
+
+      It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
+      because adding +-0.5 in this case will cause an erroneous shift,
+      carry and round.  We simply return 0 if 0.5 > x > -0.5.  Likewise
+      if x is and odd number between +-(2^23 and 2^24-1) a shift and
+      carry will erroneously round if biased with +-0.5.  Therefore if x
+      is greater/less than +-2^23 we don't need to bias the number with
+      +-0.5.  */
+
+  float ax = fabsf (x);
+
+  if (ax < 0.5f)
+    return 0;
+
+  if (ax < 0x1p+23f)
+    {
+      /* Test whether an integer to avoid spurious "inexact".  */
+      float t = ax + 0x1p+23f;
+      t = t - 0x1p+23f;
+      if (ax != t)
+	{
+	  ax = ax + 0.5f;
+	  if (x < 0.0f)
+	    ax = -fabs (ax);
+	  x = ax;
+	}
+    }
+
+  long int ret;
+  __asm__ ("fctidz %0, %1" : "=d" (ret) : "d" (x));
+  return ret;
+#endif
+}
+#ifndef __llroundf
+strong_alias (__llroundf, __lroundf)
+libm_alias_float (__llround, lround)
+libm_alias_float (__llround, llround)
+#endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lround.S b/sysdeps/powerpc/powerpc64/fpu/s_lround.S
deleted file mode 100644
index 4306c405c4..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_lround.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __lround is in s_llround.S  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lround.c b/sysdeps/powerpc/powerpc64/fpu/s_lround.c
new file mode 100644
index 0000000000..bec5026777
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_lround.c
@@ -0,0 +1 @@
+/* lround is implemented at s_llround.c as an alias to lround.  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S b/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S
deleted file mode 100644
index 6b2a4e37a6..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __lroundf is in s_llroundf.S  */
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lroundf.c b/sysdeps/powerpc/powerpc64/fpu/s_lroundf.c
new file mode 100644
index 0000000000..30400277f8
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/s_lroundf.c
@@ -0,0 +1 @@
+/* __lroundf is in s_llroundf.c  */
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S
deleted file mode 100644
index 7a37808bb0..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/* llround function.  POWER5+, PowerPC64 version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* long long [r3] llround (float x [fp1])
-   IEEE 1003.1 llround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we pre-round using the V2.02 Floating Round to Integer Nearest
-   instruction before we use Floating Convert to Integer Word with
-   round to zero instruction.  */
-
-	.machine	"power5"
-ENTRY_TOCLESS (__llround, 4)
-	CALL_MCOUNT 0
-	frin	fp2, fp1	/* Round to nearest +-0.5.  */
-	fctidz	fp3, fp2	/* Convert To Integer DW round toward 0.  */
-	stfd	fp3, -16(r1)
-	nop	/* Insure the following load is in a different dispatch group */
-	nop	/* to avoid pipe stall on POWER4&5.  */
-	nop
-	ld	r3, -16(r1)
-	blr
-	END (__llround)
-
-strong_alias (__llround, __lround)
-libm_alias_double (__llround, llround)
-libm_alias_double (__lround, lround)
-/* The double version also works for single-precision as both float and
-   double parameters are passed in 64bit FPRs and both versions are expected
-   to return [long] long type.  */
-strong_alias (__llround, __llroundf)
-libm_alias_float (__llround, llround)
-strong_alias (__lround, __lroundf)
-libm_alias_float (__lround, lround)
diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_llroundf.S
deleted file mode 100644
index 9ea6bd105b..0000000000
--- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_llroundf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __lroundf is in s_llround.S.  */
diff --git a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S
deleted file mode 100644
index ad9010ab37..0000000000
--- a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/* llround function.  POWER6x PowerPC64 version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* long long [r3] llround (float x [fp1])
-   IEEE 1003.1 llround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we pre-round using the V2.02 Floating Round to Integer Nearest
-   instruction before we use Floating Convert to Integer Word with
-   round to zero instruction.  */
-
-	.machine	"power6"
-ENTRY_TOCLESS (__llround)
-	CALL_MCOUNT 0
-	frin	fp2,fp1	/* Round to nearest +-0.5.  */
-	fctidz	fp3,fp2	/* Convert To Integer DW round toward 0.  */
-	mftgpr	r3,fp3  /* Transfer integer to R3.  */
-	blr
-	END (__llround)
-
-strong_alias (__llround, __lround)
-libm_alias_double (__llround, llround)
-libm_alias_double (__lround, lround)
-/* The double version also works for single-precision as both float and
-   double parameters are passed in 64bit FPRs and both versions are expected
-   to return [long] long type.  */
-strong_alias (__llround, __llroundf)
-libm_alias_float (__llround, llround)
-strong_alias (__lround, __lroundf)
-libm_alias_float (__lround, lround)
diff --git a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc64/power6x/fpu/s_llroundf.S
deleted file mode 100644
index 9ea6bd105b..0000000000
--- a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llroundf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __lroundf is in s_llround.S.  */
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S
deleted file mode 100644
index 12081204e2..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S
+++ /dev/null
@@ -1,46 +0,0 @@
-/* llround function.  POWER8 PowerPC64 version.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <endian.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-#define MFVSRD_R3_V1  .long 0x7c230066     /* mfvsrd  r3,vs1  */
-
-/* long long [r3] llround (float x [fp1])  */
-
-ENTRY_TOCLESS (__llround)
-	CALL_MCOUNT 0
-	frin	fp1,fp1	/* Round to nearest +-0.5.  */
-	fctidz	fp1,fp1	/* Convert To Integer DW round toward 0.  */
-	MFVSRD_R3_V1
-	blr
-END (__llround)
-
-strong_alias (__llround, __lround)
-libm_alias_double (__llround, llround)
-libm_alias_double (__lround, lround)
-/* The double version also works for single-precision as both float and
-   double parameters are passed in 64bit FPRs and both versions are expected
-   to return [long] long type.  */
-strong_alias (__llround, __llroundf)
-libm_alias_float (__llround, llround)
-strong_alias (__lround, __lroundf)
-libm_alias_float (__lround, lround)
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_llroundf.S
deleted file mode 100644
index 9ea6bd105b..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/s_llroundf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __lroundf is in s_llround.S.  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (19 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 20/28] powerpc: Refactor powerpc64 lround/lroundf/llround/llroundf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-24 21:07   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 22/28] powerpc: Use generic e_expf Adhemerval Zanella
                   ` (6 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

This patches consolidates all the powerpc llround{f} implementations on
the generic sysdeps/powerpc/powerpc32/fpu/s_llround{f}.  The only missing
optimization is the power6x one which I could not make GCC generates
mftgpr for 32 bits output.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/powerpc32/fpu/Makefile
	[$(subdir) == math] (CFLAGS-s_lround.c): New rule.
	* sysdeps/powerpc/powerpc32/fpu/s_llround.c (__llround): Add power5+
	and fctidz optimization.
	* sysdeps/powerpc/powerpc32/fpu/s_lround.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_lround.c: New file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
	(CFLAGS-s_llround-power6.c, CFLAGS-s_llround-power5+.c,
	CFLAGS-s_llround-ppc32.c, CFLAGS-s_lround-ppc32.c,
	CFLAGS-s_lround-power5+.c): New rule.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.c:
	New file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.S:
	Remove file.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.S:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llroundf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_llroundf.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llroundf.S: Likewise.
---
 sysdeps/powerpc/powerpc32/fpu/Makefile        |   1 +
 sysdeps/powerpc/powerpc32/fpu/s_llround.c     |  51 +++++++-
 sysdeps/powerpc/powerpc32/fpu/s_lround.S      | 123 ------------------
 sysdeps/powerpc/powerpc32/fpu/s_lround.c      |  77 +++++++++++
 .../powerpc32/power4/fpu/multiarch/Makefile   |   5 +
 .../power4/fpu/multiarch/s_llround-power5+.S  |  31 -----
 .../power4/fpu/multiarch/s_llround-power5+.c  |   2 +
 .../power4/fpu/multiarch/s_llround-power6.S   |  31 -----
 .../power4/fpu/multiarch/s_llround-power6.c   |   2 +
 .../power4/fpu/multiarch/s_llround-ppc32.S    |  31 -----
 .../power4/fpu/multiarch/s_llround-ppc32.c    |   2 +
 .../power4/fpu/multiarch/s_lround-power5+.S   |  33 -----
 .../power4/fpu/multiarch/s_lround-power5+.c   |   2 +
 .../power4/fpu/multiarch/s_lround-ppc32.S     |  31 -----
 .../power4/fpu/multiarch/s_lround-ppc32.c     |   2 +
 .../powerpc/powerpc32/power4/fpu/s_llround.S  | 105 ---------------
 .../powerpc/powerpc32/power4/fpu/s_llroundf.S |   1 -
 .../powerpc/powerpc32/power5+/fpu/s_llround.S |  53 --------
 .../powerpc32/power5+/fpu/s_llroundf.S        |   1 -
 .../powerpc/powerpc32/power5+/fpu/s_lround.S  |  51 --------
 .../powerpc/powerpc32/power6/fpu/s_llround.S  |  53 --------
 .../powerpc/powerpc32/power6/fpu/s_llroundf.S |   1 -
 22 files changed, 142 insertions(+), 547 deletions(-)
 delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lround.S
 create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_lround.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.S
 create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_llroundf.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S
 delete mode 100644 sysdeps/powerpc/powerpc32/power6/fpu/s_llroundf.S

diff --git a/sysdeps/powerpc/powerpc32/fpu/Makefile b/sysdeps/powerpc/powerpc32/fpu/Makefile
index c79b192f60..b8b6bb0fa2 100644
--- a/sysdeps/powerpc/powerpc32/fpu/Makefile
+++ b/sysdeps/powerpc/powerpc32/fpu/Makefile
@@ -2,6 +2,7 @@ ifeq ($(subdir),math)
 # lrint is aliased to lrintf, so suppress compiler builtins to
 # avoid mismatched signatures.
 CFLAGS-s_lrint.c += -fno-builtin-lrintf
+CFLAGS-s_lround.c += -fno-builtin-lroundf
 endif
 
 ifeq ($(subdir),misc)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_llround.c b/sysdeps/powerpc/powerpc32/fpu/s_llround.c
index 14d10e1e63..dc9f41b8e7 100644
--- a/sysdeps/powerpc/powerpc32/fpu/s_llround.c
+++ b/sysdeps/powerpc/powerpc32/fpu/s_llround.c
@@ -18,10 +18,10 @@
 
 #include <limits.h>
 #include <math.h>
-#include <math_ldbl_opt.h>
 #include <math_private.h>
 #include <stdint.h>
 #include <libm-alias-double.h>
+#include <math-barriers.h>
 
 /* Round to the nearest integer, with values exactly on a 0.5 boundary
    rounded away from zero, regardless of the current rounding mode.
@@ -31,9 +31,53 @@
 long long int
 __llround (double x)
 {
+#ifdef _ARCH_PWR5X
+  x = round (x);
+  /* The barrier prevents compiler from optimizing it to llround when
+     compiled with -fno-math-errno */
+  math_opt_barrier (x);
+  return x;
+#else
   long long xr;
   if (HAVE_PPC_FCTIDZ)
-    xr = (long long) x;
+    {
+       /* IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
+	  integer value, rounding halfway cases away from zero, regardless of
+	  the current rounding mode."  However PowerPC Architecture defines
+	  "round to Nearest" as "Choose the best approximation. In case of a
+	  tie, choose the one that is even (least significant bit o).".
+	  So we can't use the PowerPC "round to Nearest" mode. Instead we set
+	  "round toward Zero" mode and round by adding +-0.5 before rounding
+	  to the integer value.
+  
+	  It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
+	  because adding +-0.5 in this case will cause an erroneous shift,
+	  carry and round.  We simply return 0 if 0.5 > x > -0.5.  Likewise
+	  if x is and odd number between +-(2^52 and 2^53-1) a shift and
+	  carry will erroneously round if biased with +-0.5.  Therefore if x
+	  is greater/less than +-2^52 we don't need to bias the number with
+	  +-0.5.  */
+      double ax = fabs (x);
+
+      if (ax < 0.5)
+	return 0;
+
+      if (ax < 0x1p+52)
+	{
+	  /* Test whether an integer to avoid spurious "inexact".  */
+	  double t = ax + 0x1p+52;
+	  t = t - 0x1p+52;
+	  if (ax != t)
+	    {
+	      ax = ax + 0.5;
+	      if (x < 0.0)
+		ax = -fabs (ax);
+	      x = ax;
+	    }
+        }
+
+      return x;
+    }
   else
     {
       /* Avoid incorrect exceptions from libgcc conversions (as of GCC
@@ -80,5 +124,8 @@ __llround (double x)
 	xr -= (long long) ((unsigned long long) xr - 1) < 0;
     }
   return xr;
+#endif
 }
+#ifndef __llround
 libm_alias_double (__llround, llround)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lround.S b/sysdeps/powerpc/powerpc32/fpu/s_lround.S
deleted file mode 100644
index 2d9540ceed..0000000000
--- a/sysdeps/powerpc/powerpc32/fpu/s_lround.S
+++ /dev/null
@@ -1,123 +0,0 @@
-/* lround function.  PowerPC32 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-	.section	.rodata.cst4,"aM",@progbits,4
-	.align	2
-.LC0:	/* 0.5 */
-	.long 0x3f000000
-.LC1:	/* 2^52.  */
-	.long 0x59800000
-	.section	.rodata.cst8,"aM",@progbits,8
-	.align	3
-.LC2:	/* 0x7fffffff.8p0.  */
-	.long 0x41dfffff
-	.long 0xffe00000
-.LC3:	/* -0x80000000.8p0.  */
-	.long 0xc1e00000
-	.long 0x00100000
-	.section	".text"
-
-/* long [r3] lround (float x [fp1])
-   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "round to Nearest" mode. Instead we set
-   "round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.  It is necessary to detect when x is
-   (+-)0x1.fffffffffffffp-2 because adding +-0.5 in this case will
-   cause an erroneous shift, carry and round.  We simply return 0 if
-   0.5 > x > -0.5.  */
-
-ENTRY (__lround)
-	stwu    r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r10,r9,.LC0-got_label@ha
-	lfs	fp10,.LC0-got_label@l(r10)
-	addis	r10,r9,.LC1-got_label@ha
-	lfs	fp11,.LC1-got_label@l(r10)
-	addis	r10,r9,.LC2-got_label@ha
-	lfd	fp9,.LC2-got_label@l(r10)
-	addis	r10,r9,.LC3-got_label@ha
-	lfd	fp8,.LC3-got_label@l(r10)
-	mtlr	r11
-	cfi_same_value (lr)
-#else
-	lis	r9,.LC0@ha
-	lfs	fp10,.LC0@l(r9)
-	lis	r9,.LC1@ha
-	lfs	fp11,.LC1@l(r9)
-	lis	r9,.LC2@ha
-	lfd	fp9,.LC2@l(r9)
-	lis	r9,.LC3@ha
-	lfd	fp8,.LC3@l(r9)
-#endif
-	fabs	fp2, fp1	/* Get the absolute value of x.  */
-	fsub	fp12,fp10,fp10	/* Compute 0.0.  */
-	fcmpu	cr6, fp2, fp10	/* if |x| < 0.5  */
-	fcmpu	cr5, fp1, fp9	/* if x >= 0x7fffffff.8p0  */
-	fcmpu	cr1, fp1, fp8	/* if x <= -0x80000000.8p0  */
-	fcmpu	cr7, fp1, fp12	/* x is negative? x < 0.0  */
-	blt-	cr6,.Lretzero
-	bge-	cr5,.Loflow
-	ble-	cr1,.Loflow
-	/* Test whether an integer to avoid spurious "inexact".  */
-	fadd	fp3,fp2,fp11
-	fsub	fp3,fp3,fp11
-	fcmpu	cr5, fp2, fp3
-	beq	cr5,.Lnobias
-	fadd	fp3,fp2,fp10	/* |x|+=0.5 bias to prepare to round.  */
-	bge	cr7,.Lconvert	/* x is positive so don't negate x.  */
-	fnabs	fp3,fp3		/* -(|x|+=0.5)  */
-.Lconvert:
-	fctiwz	fp4,fp3		/* Convert to Integer word lround toward 0.  */
-	stfd	fp4,8(r1)
-	nop	/* Ensure the following load is in a different dispatch  */
-	nop	/* group to avoid pipe stall on POWER4&5.  */
-	nop
-	lwz	r3,8+LOWORD(r1)	/* Load return as integer.  */
-.Lout:
-	addi	r1,r1,16
-	blr
-.Lretzero:			/* when 0.5 > x > -0.5  */
-	li	r3,0		/* return 0.  */
-	b	.Lout
-.Lnobias:
-	fmr	fp3,fp1
-	b	.Lconvert
-.Loflow:
-	fmr	fp3,fp11
-	bge	cr7,.Lconvert
-	fnabs	fp3,fp3
-	b	.Lconvert
-	END (__lround)
-
-libm_alias_double (__lround, lround)
-
-strong_alias (__lround, __lroundf)
-libm_alias_float (__lround, lround)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lround.c b/sysdeps/powerpc/powerpc32/fpu/s_lround.c
new file mode 100644
index 0000000000..28c06d25d2
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/s_lround.c
@@ -0,0 +1,77 @@
+/* lround function.  PowerPC32 version.
+   Copyright (C) 2004-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define lroundf __redirect_lroundf
+#define __lroundf __redirect___lroundf
+#include <math.h>
+#undef lroundf
+#undef __lroundf
+#include <libm-alias-float.h>
+#include <libm-alias-double.h>
+
+long int
+__lround (double x)
+{
+#ifdef _ARCH_PWR5X
+  x = round (x);
+#else
+  /* Ieee 1003.1 lround function.  ieee specifies "round to the nearest
+     integer value, rounding halfway cases away from zero, regardless of
+     the current rounding mode."  however powerpc architecture defines
+     "round to nearest" as "choose the best approximation. in case of a
+     tie, choose the one that is even (least significant bit o).".
+     so we can't use the powerpc "round to nearest" mode. instead we set
+     "round toward zero" mode and round by adding +-0.5 before rounding
+     to the integer value.  it is necessary to detect when x is
+     (+-)0x1.fffffffffffffp-2 because adding +-0.5 in this case will
+     cause an erroneous shift, carry and round.  we simply return 0 if
+     0.5 > x > -0.5.  */
+
+  double ax = fabs (x);
+
+  if (ax < 0.5)
+    return 0;
+
+  if (x >= 0x7fffffff.8p0 || x <= -0x80000000.8p0)
+    x = (x < 0.0) ? -0x1p+52 : 0x1p+52;
+  else
+    {
+      /* Test whether an integer to avoid spurious "inexact".  */
+      double t = ax + 0x1p+52;
+      t = t - 0x1p+52;
+      if (ax != t)
+        {
+	  ax = ax + 0.5;
+	  if (x < 0.0)
+	    ax = -fabs (ax);
+	  x = ax;
+        }
+    }
+#endif
+  /* Force evaluation of values larger than long int, so invalid
+     exceptions are raise.  */
+  long long int ret;
+  asm ("fctiwz %0, %1" : "=d" (ret) : "d" (x));
+  return ret;
+}
+#ifndef __lround
+libm_alias_double (__lround, lround)
+
+strong_alias (__lround, __lroundf)
+libm_alias_float (__lround, lround)
+#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index d33d403a1b..60f2c95532 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -23,6 +23,11 @@ CFLAGS-s_llrintf-ppc32.c += -mcpu=power4
 CFLAGS-s_llrint-power6.c += -mcpu=power6
 CFLAGS-s_llrint-ppc32.c += -mcpu=power4
 CFLAGS-s_lrint-ppc32.c += -mcpu=power4
+CFLAGS-s_llround-power6.c += -mcpu=power6
+CFLAGS-s_llround-power5+.c += -mcpu=power5+
+CFLAGS-s_llround-ppc32.c += -mcpu=power4
+CFLAGS-s_lround-ppc32.c += -mcpu=power4
+CFLAGS-s_lround-power5+.c += -mcpu=power5+
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
 CFLAGS-s_modf-power5+.c = -mcpu=power5+
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.S
deleted file mode 100644
index 80fc5b0f6c..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* lround function.  PowerPC32/POWER5+ version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llround __llround_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.c
new file mode 100644
index 0000000000..794fad71c2
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power5+.c
@@ -0,0 +1,2 @@
+#define __llround __llround_power5plus
+#include <sysdeps/powerpc/powerpc32/fpu/s_llround.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.S
deleted file mode 100644
index d6d9a0a4cb..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* lround function.  PowerPC32/POWER6 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llround __llround_power6
-
-#include <sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c
new file mode 100644
index 0000000000..2b588c4c54
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c
@@ -0,0 +1,2 @@
+#define __llround __llround_power6
+#include <sysdeps/powerpc/powerpc32/fpu/s_llround.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.S
deleted file mode 100644
index 085fbc6de4..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* llround function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __llround __llround_ppc32
-
-#include <sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.c
new file mode 100644
index 0000000000..3b5ff344bd
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-ppc32.c
@@ -0,0 +1,2 @@
+#define __llround __llround_ppc32
+#include <sysdeps/powerpc/powerpc32/fpu/s_llround.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.S
deleted file mode 100644
index 350315e38b..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* lround function.  POWER5+, PowerPC32 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef hidden_def
-#define hidden_def(name)
-#undef weak_alias
-#define weak_alias(name, alias)
-#undef strong_alias
-#define strong_alias(name, alias)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
-#define __lround __lround_power5plus
-
-#include <sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.c
new file mode 100644
index 0000000000..d6a17c4bca
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-power5+.c
@@ -0,0 +1,2 @@
+#define __lround __lround_power5plus
+#include <sysdeps/powerpc/powerpc32/fpu/s_lround.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.S
deleted file mode 100644
index 245a682720..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* lround function.  PowerPC32 default version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
-#define __lround __lround_ppc32
-
-#include <sysdeps/powerpc/powerpc32/fpu/s_lround.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.c
new file mode 100644
index 0000000000..5355e1f712
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround-ppc32.c
@@ -0,0 +1,2 @@
+#define __lround __lround_ppc32
+#include <sysdeps/powerpc/powerpc32/fpu/s_lround.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S b/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S
deleted file mode 100644
index 3d6ba34180..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S
+++ /dev/null
@@ -1,105 +0,0 @@
-/* llround function.  PowerPC32 on PowerPC64 version.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
- .section .rodata.cst8,"aM",@progbits,8
- .align 3
- .LC0:	.long (52+127)<<23 /* 0x1p+52  */
-	.long (-1+127)<<23 /* 0.5  */
-
-	.section	".text"
-
-/* long [r3] lround (float x [fp1])
-   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we can't use the PowerPC "round to Nearest" mode. Instead we set
-   "round toward Zero" mode and round by adding +-0.5 before rounding
-   to the integer value.
-
-   It is necessary to detect when x is (+-)0x1.fffffffffffffp-2
-   because adding +-0.5 in this case will cause an erroneous shift,
-   carry and round.  We simply return 0 if 0.5 > x > -0.5.  Likewise
-   if x is and odd number between +-(2^52 and 2^53-1) a shift and
-   carry will erroneously round if biased with +-0.5.  Therefore if x
-   is greater/less than +-2^52 we don't need to bias the number with
-   +-0.5.  */
-
-ENTRY (__llround)
-	stwu    r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-#ifdef SHARED
-	mflr	r11
-	cfi_register(lr,r11)
-	SETUP_GOT_ACCESS(r9,got_label)
-	addis	r9,r9,.LC0-got_label@ha
-	addi	r9,r9,.LC0-got_label@l
-	mtlr	r11
-	cfi_same_value (lr)
-	lfs	fp9,0(r9)
-	lfs	fp10,4(r9)
-#else
-	lis r9,.LC0@ha
-	lfs fp9,.LC0@l(r9)	/* Load 2^52 into fpr9.  */
-	lfs fp10,.LC0@l+4(r9)	/* Load 0.5 into fpr10.  */
-#endif
-	fabs	fp2,fp1		/* Get the absolute value of x.  */
-	fsub	fp12,fp10,fp10	/* Compute 0.0 into fpr12.  */
-	fcmpu	cr6,fp2,fp10	/* if |x| < 0.5  */
-	fcmpu	cr7,fp2,fp9	/* if |x| >= 2^52  */
-	fcmpu	cr1,fp1,fp12	/* x is negative? x < 0.0  */
-	blt-	cr6,.Lretzero	/* 0.5 > x < -0.5 so just return 0.  */
-	bge-	cr7,.Lnobias	/* 2^52 > x < -2^52 just convert with no bias.  */
-	/* Test whether an integer to avoid spurious "inexact".  */
-	fadd	fp3,fp2,fp9
-	fsub	fp3,fp3,fp9
-	fcmpu	cr5,fp2,fp3
-	beq	cr5,.Lnobias
-	fadd	fp3,fp2,fp10	/* |x|+=0.5 bias to prepare to round.  */
-	bge	cr1,.Lconvert	/* x is positive so don't negate x.  */
-	fnabs	fp3,fp3		/* -(|x|+=0.5)  */
-.Lconvert:
-	fctidz	fp4,fp3		/* Convert to Integer double word round toward 0.  */
-	stfd	fp4,8(r1)
-	nop
-	nop
-	nop
-	lwz	r3,8+HIWORD(r1)	/* Load return as integer.  */
-	lwz	r4,8+LOWORD(r1)
-.Lout:
-	addi	r1,r1,16
-	blr
-.Lretzero:			/* 0.5 > x > -0.5  */
-	li	r3,0		/* return 0.  */
-	li	r4,0
-	b	.Lout
-.Lnobias:
-	fmr	fp3,fp1
-	b	.Lconvert
-	END (__llround)
-
-libm_alias_double (__llround, llround)
-
-strong_alias (__llround, __llroundf)
-libm_alias_float (__llround, llround)
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc32/power4/fpu/s_llroundf.S
deleted file mode 100644
index 72d6181541..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/fpu/s_llroundf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __llroundf is in s_llround.S */
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S
deleted file mode 100644
index 5035170d94..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/* lround function.  POWER5+, PowerPC32 version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* long [r3] llround (float x [fp1])
-   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we pre-round using the V2.02 Floating Round to Integer Nearest
-   instruction before we use the Floating Convert to Integer Word with
-   round to zero instruction.  */
-
-	.machine	"power5"
-ENTRY (__llround)
-	stwu    r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	frin	fp2,fp1
-	fctidz	fp3,fp2		/* Convert To Integer Word lround toward 0.  */
-	stfd	fp3,8(r1)
-	nop	/* Ensure the following load is in a different dispatch  */
-	nop	/* group to avoid pipe stall on POWER4&5.  */
-	nop
-	lwz	r3,8+HIWORD(r1)
-	lwz	r4,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__llround)
-
-libm_alias_double (__llround, llround)
-
-strong_alias (__llround, __llroundf)
-libm_alias_float (__llround, llround)
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_llroundf.S
deleted file mode 100644
index 030d2fdff8..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_llroundf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __llroundf is in s_llround.S  */
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
deleted file mode 100644
index f30a0bff3e..0000000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/* lround function.  POWER5+, PowerPC32 version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* long [r3] lround (float x [fp1])
-   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we pre-round using the V2.02 Floating Round to Integer Nearest
-   instruction before we use the Floating Convert to Integer Word with
-   round to zero instruction.  */
-
-	.machine	"power5"
-ENTRY (__lround)
-	stwu    r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	frin	fp2,fp1
-	fctiwz	fp3,fp2		/* Convert To Integer Word lround toward 0.  */
-	stfd	fp3,8(r1)
-	nop	/* Ensure the following load is in a different dispatch  */
-	nop	/* group to avoid pipe stall on POWER4&5.  */
-	nop
-	lwz	r3,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__lround)
-
-libm_alias_double (__lround, lround)
-
-strong_alias (__lround, __lroundf)
-libm_alias_float (__lround, lround)
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S
deleted file mode 100644
index 7ba312cc6b..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/* lround function.  POWER5+, PowerPC32 version.
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-float.h>
-#include <libm-alias-double.h>
-
-/* long [r3] llround (float x [fp1])
-   IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
-   integer value, rounding halfway cases away from zero, regardless of
-   the current rounding mode."  However PowerPC Architecture defines
-   "round to Nearest" as "Choose the best approximation. In case of a
-   tie, choose the one that is even (least significant bit o).".
-   So we pre-round using the V2.02 Floating Round to Integer Nearest
-   instruction before we use the Floating Convert to Integer Word with
-   round to zero instruction.  */
-
-	.machine	"power5"
-ENTRY (__llround)
-	stwu    r1,-16(r1)
-	cfi_adjust_cfa_offset (16)
-	frin	fp2,fp1
-	fctidz	fp3,fp2		/* Convert To Integer Word lround toward 0.  */
-	stfd	fp3,8(r1)
-/* Insure the following load is in a different dispatch group by
-   inserting "group ending nop".  */
-	ori	r1,r1,0
-	lwz	r3,8+HIWORD(r1)
-	lwz	r4,8+LOWORD(r1)
-	addi	r1,r1,16
-	blr
-	END (__llround)
-
-libm_alias_double (__llround, llround)
-
-strong_alias (__llround, __llroundf)
-libm_alias_float (__llround, llround)
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_llroundf.S
deleted file mode 100644
index 030d2fdff8..0000000000
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_llroundf.S
+++ /dev/null
@@ -1 +0,0 @@
-/* __llroundf is in s_llround.S  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 22/28] powerpc: Use generic e_expf
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (20 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-26 12:59   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 23/28] benchtests: hypot benchmark Adhemerval Zanella
                   ` (5 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

Generic implementation is faster on both power8 and power9:

  POWER9:
  - sysdeps/ieee754/flt-32/e_expf.c
    "expf": {
     "workload-spec2017.wrf": {
      "duration": 5.1236e+09,
      "iterations": 7.53344e+08,
      "reciprocal-throughput": 5.9436,
      "latency": 7.65869,
      "max-throughput": 1.68248e+08,
      "min-throughput": 1.30571e+08
     }
    }

  - sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
    "expf": {
     "workload-spec2017.wrf": {
      "duration": 5.14429e+09,
      "iterations": 5.29248e+08,
      "reciprocal-throughput": 8.05372,
      "latency": 11.3863,
      "max-throughput": 1.24166e+08,
      "min-throughput": 8.78249e+07
     }
    }

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove e_expf-power8 and expf-ppc64.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S: Remove
	file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S: Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c: Likewise.
---
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |   1 -
 .../powerpc64/fpu/multiarch/e_expf-power8.S   |  24 --
 .../powerpc64/fpu/multiarch/e_expf-ppc64.c    |  21 --
 .../powerpc/powerpc64/fpu/multiarch/e_expf.c  |  32 --
 .../powerpc/powerpc64/fpu/multiarch/w_expf.c  |   1 -
 sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S | 303 ------------------
 sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c |   1 -
 7 files changed, 383 deletions(-)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
 delete mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c

diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 48cf8dca3b..118865a1a9 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -10,7 +10,6 @@ libm-sysdep_routines += s_logb-power7 s_logbf-power7 \
 			s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
 			s_logbl-ppc64 e_hypot-ppc64 \
 			e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
-			e_expf-power8 e_expf-ppc64 \
 			$(sysdep_calls:s_%=m_%)
 
 CFLAGS-s_logbf-power7.c = -mcpu=power7
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S
deleted file mode 100644
index e0e14c2a47..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* __ieee754_expf() POWER8 version.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define __ieee754_expf __ieee754_expf_power8
-
-#include <sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
deleted file mode 100644
index 00c2006d41..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* __ieee_expf() PowerPC64 version.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __expf __ieee754_expf_ppc64
-
-#include <sysdeps/ieee754/flt-32/e_expf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
deleted file mode 100644
index dc0023c244..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Multiple versions of ieee754_expf.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math_private.h>
-#include <math_ldbl_opt.h>
-#include "init-arch.h"
-
-extern __typeof (__ieee754_expf) __ieee754_expf_ppc64 attribute_hidden;
-extern __typeof (__ieee754_expf) __ieee754_expf_power8 attribute_hidden;
-
-libc_ifunc (__ieee754_expf,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-	    ? __ieee754_expf_power8
-	    : __ieee754_expf_ppc64);
-
-strong_alias (__ieee754_expf, __expf_finite)
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c
deleted file mode 100644
index b5fe164520..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/../math/w_expf.c>
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S b/sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
deleted file mode 100644
index 7469a72873..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
+++ /dev/null
@@ -1,303 +0,0 @@
-/* Optimized expf().  PowerPC64/POWER8 version.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-/* Short algorithm description:
- *
- *  Let K = 64 (table size).
- *       e^x  = 2^(x/log(2)) = 2^n * T[j] * (1 + P(y))
- *  where:
- *       x = m*log(2)/K + y,    y in [0.0..log(2)/K]
- *       m = n*K + j,           m,n,j - signed integer, j in [0..K-1]
- *       values of 2^(j/K) are tabulated as T[j].
- *
- *       P(y) is a minimax polynomial approximation of expf(y)-1
- *       on small interval [0.0..log(2)/K].
- *
- *       P(y) = P3*y*y*y*y + P2*y*y*y + P1*y*y + P0*y, calculated as
- *       z = y*y;    P(y) = (P3*z + P1)*z + (P2*z + P0)*y
- *
- * Special cases:
- *  expf(NaN) = NaN
- *  expf(+INF) = +INF
- *  expf(-INF) = 0
- *  expf(x) = 1 for subnormals
- *  for finite argument, only expf(0)=1 is exact
- *  expf(x) overflows if x>88.7228317260742190
- *  expf(x) underflows if x<-103.972076416015620
- */
-
-#define C1 0x42ad496b		/* Single precision 125*log(2).  */
-#define C2 0x31800000		/* Single precision 2^(-28).  */
-#define SP_INF 0x7f800000	/* Single precision Inf.  */
-#define SP_EXP_BIAS 0x1fc0	/* Single precision exponent bias.  */
-
-#define DATA_OFFSET r9
-
-/* Implements the function
-
-   float [fp1] expf (float [fp1] x)  */
-
-	.machine power8
-ENTRY (__ieee754_expf, 4)
-	addis	DATA_OFFSET,r2,.Lanchor@toc@ha
-	addi	DATA_OFFSET,DATA_OFFSET,.Lanchor@toc@l
-
-	xscvdpspn v0,v1
-	mfvsrd	r8,v0		/* r8 = x  */
-	lfd	fp2,(.KLN2-.Lanchor)(DATA_OFFSET)
-	lfd	fp3,(.P2-.Lanchor)(DATA_OFFSET)
-	rldicl	r3,r8,32,33	/* r3 = |x|  */
-	lis	r4,C1@ha	/* r4 = 125*log(2)  */
-	ori	r4,r4,C1@l
-	cmpw	r3,r4
-	lfd	fp5,(.P3-.Lanchor)(DATA_OFFSET)
-	lfd	fp4,(.RS-.Lanchor)(DATA_OFFSET)
-	fmadd	fp2,fp1,fp2,fp4	/* fp2 = x * K/log(2) + (2^23 + 2^22)  */
-	bge	L(special_paths)	/* |x| >= 125*log(2) ?  */
-
-	lis	r4,C2@ha
-	ori	r4,r4,C2@l
-	cmpw	r3,r4
-	blt	L(small_args)	/* |x| < 2^(-28) ?  */
-
-	/* Main path: here if 2^(-28) <= |x| < 125*log(2) */
-	frsp	fp6,fp2
-	xscvdpsp v2,v2
-	mfvsrd	r8,v2
-	mr	r3,r8			/* r3 = m  */
-	rldicl	r8,r8,32,58		/* r8 = j  */
-	lfs	fp4,(.SP_RS-.Lanchor)(DATA_OFFSET)
-	fsubs	fp2,fp6,fp4		/* fp2 = m = x * K/log(2)  */
-	srdi	r3,r3,32
-	clrrwi	r3,r3,6			/* r3 = n  */
-	lfd	fp6,(.NLN2K-.Lanchor)(DATA_OFFSET)
-	fmadd	fp0,fp2,fp6,fp1		/* fp0 = y = x - m*log(2)/K  */
-	fmul	fp2,fp0,fp0		/* fp2 = z = y^2  */
-	lfd	fp4,(.P1-.Lanchor)(DATA_OFFSET)
-	lfd	fp6,(.P0-.Lanchor)(DATA_OFFSET)
-	lis	r4,SP_EXP_BIAS@ha
-	ori	r4,r4,SP_EXP_BIAS@l
-	add	r3,r3,r4
-	rldic	r3,r3,49,1		/* r3 = 2^n  */
-	fmadd	fp4,fp5,fp2,fp4		/* fp4 = P3 * z + P1  */
-	fmadd	fp6,fp3,fp2,fp6		/* fp6 = P2 * z + P0  */
-	mtvsrd	v1,r3
-	xscvspdp v1,v1
-	fmul	fp4,fp4,fp2		/* fp4 = (P3 * z + P1)*z  */
-	fmadd	fp0,fp0,fp6,fp4		/* fp0 = P(y)  */
-	sldi	r8,r8,3			/* Access doublewords from T[j].  */
-	addi	r6,DATA_OFFSET,(.Ttable-.Lanchor)
-	lfdx	fp3,r6,r8
-	fmadd	fp0,fp0,fp3,fp3		/* fp0 = T[j] * (1 + P(y))  */
-	fmul	fp1,fp1,fp0		/* fp1 = 2^n * T[j] * (1 + P(y))  */
-	frsp	fp1,fp1
-	blr
-
-	.align	4
-/* x is either underflow, overflow, infinite or NaN.  */
-L(special_paths):
-	srdi	r8,r8,32
-	rlwinm	r8,r8,3,29,29		/* r8 = 0, if x positive.
-					   r8 = 4, otherwise.  */
-	addi	r6,DATA_OFFSET,(.SPRANGE-.Lanchor)
-	lwzx	r4,r6,r8		/* r4 = .SPRANGE[signbit(x)]  */
-	cmpw	r3,r4
-	/* |x| <= .SPRANGE[signbit(x)]  */
-	ble	L(near_under_or_overflow)
-
-	lis	r4,SP_INF@ha
-	ori	r4,r4,SP_INF@l
-	cmpw	r3,r4
-	bge	L(arg_inf_or_nan)	/* |x| > Infinite ?  */
-
-	addi	r6,DATA_OFFSET,(.SPLARGE_SMALL-.Lanchor)
-	lfsx	fp1,r6,r8
-	fmuls	fp1,fp1,fp1
-	blr
-
-
-	.align	4
-L(small_args):
-	/* expf(x) = 1.0, where |x| < |2^(-28)|  */
-	lfs	fp2,(.SPone-.Lanchor)(DATA_OFFSET)
-	fadds	fp1,fp1,fp2
-	blr
-
-
-	.align	4
-L(arg_inf_or_nan:)
-	bne	L(arg_nan)
-
-	/* expf(+INF) = +INF
-	   expf(-INF) = 0  */
-	addi	r6,DATA_OFFSET,(.INF_ZERO-.Lanchor)
-	lfsx	fp1,r6,r8
-	blr
-
-
-	.align	4
-L(arg_nan):
-	/* expf(NaN) = NaN  */
-	fadd	fp1,fp1,fp1
-	frsp	fp1,fp1
-	blr
-
-	.align	4
-L(near_under_or_overflow):
-	frsp	fp6,fp2
-	xscvdpsp v2,v2
-	mfvsrd	r8,v2
-	mr	r3,r8			/* r3 = m  */
-	rldicl	r8,r8,32,58		/* r8 = j  */
-	lfs	fp4,(.SP_RS-.Lanchor)(DATA_OFFSET)
-	fsubs	fp2,fp6,fp4		/* fp2 = m = x * K/log(2)  */
-	srdi	r3,r3,32
-	clrrwi	r3,r3,6			/* r3 = n  */
-	lfd	fp6,(.NLN2K-.Lanchor)(DATA_OFFSET)
-	fmadd	fp0,fp2,fp6,fp1		/* fp0 = y = x - m*log(2)/K  */
-	fmul	fp2,fp0,fp0		/* fp2 = z = y^2  */
-	lfd	fp4,(.P1-.Lanchor)(DATA_OFFSET)
-	lfd	fp6,(.P0-.Lanchor)(DATA_OFFSET)
-	ld	r4,(.DP_EXP_BIAS-.Lanchor)(DATA_OFFSET)
-	add	r3,r3,r4
-	rldic	r3,r3,46,1		/* r3 = 2  */
-	fmadd	fp4,fp5,fp2,fp4		/* fp4 = P3 * z + P1  */
-	fmadd	fp6,fp3,fp2,fp6		/* fp6 = P2 * z + P0  */
-	mtvsrd	v1,r3
-	fmul	fp4,fp4,fp2		/* fp4 = (P3*z + P1)*z  */
-	fmadd	fp0,fp0,fp6,fp4		/* fp0 = P(y)  */
-	sldi	r8,r8,3			/* Access doublewords from T[j].  */
-	addi	r6,DATA_OFFSET,(.Ttable-.Lanchor)
-	lfdx	fp3,r6,r8
-	fmadd	fp0,fp0,fp3,fp3		/* fp0 = T[j] * (1 + T[j])  */
-	fmul	fp1,fp1,fp0		/* fp1 = 2^n * T[j] * (1 + T[j])  */
-	frsp	fp1,fp1
-	blr
-END(__ieee754_expf)
-
-	.section .rodata, "a",@progbits
-.Lanchor:
-	.balign	8
-/* Table T[j] = 2^(j/K).  Double precision.  */
-.Ttable:
-	.8byte	0x3ff0000000000000
-	.8byte	0x3ff02c9a3e778061
-	.8byte	0x3ff059b0d3158574
-	.8byte	0x3ff0874518759bc8
-	.8byte	0x3ff0b5586cf9890f
-	.8byte	0x3ff0e3ec32d3d1a2
-	.8byte	0x3ff11301d0125b51
-	.8byte	0x3ff1429aaea92de0
-	.8byte	0x3ff172b83c7d517b
-	.8byte	0x3ff1a35beb6fcb75
-	.8byte	0x3ff1d4873168b9aa
-	.8byte	0x3ff2063b88628cd6
-	.8byte	0x3ff2387a6e756238
-	.8byte	0x3ff26b4565e27cdd
-	.8byte	0x3ff29e9df51fdee1
-	.8byte	0x3ff2d285a6e4030b
-	.8byte	0x3ff306fe0a31b715
-	.8byte	0x3ff33c08b26416ff
-	.8byte	0x3ff371a7373aa9cb
-	.8byte	0x3ff3a7db34e59ff7
-	.8byte	0x3ff3dea64c123422
-	.8byte	0x3ff4160a21f72e2a
-	.8byte	0x3ff44e086061892d
-	.8byte	0x3ff486a2b5c13cd0
-	.8byte	0x3ff4bfdad5362a27
-	.8byte	0x3ff4f9b2769d2ca7
-	.8byte	0x3ff5342b569d4f82
-	.8byte	0x3ff56f4736b527da
-	.8byte	0x3ff5ab07dd485429
-	.8byte	0x3ff5e76f15ad2148
-	.8byte	0x3ff6247eb03a5585
-	.8byte	0x3ff6623882552225
-	.8byte	0x3ff6a09e667f3bcd
-	.8byte	0x3ff6dfb23c651a2f
-	.8byte	0x3ff71f75e8ec5f74
-	.8byte	0x3ff75feb564267c9
-	.8byte	0x3ff7a11473eb0187
-	.8byte	0x3ff7e2f336cf4e62
-	.8byte	0x3ff82589994cce13
-	.8byte	0x3ff868d99b4492ed
-	.8byte	0x3ff8ace5422aa0db
-	.8byte	0x3ff8f1ae99157736
-	.8byte	0x3ff93737b0cdc5e5
-	.8byte	0x3ff97d829fde4e50
-	.8byte	0x3ff9c49182a3f090
-	.8byte	0x3ffa0c667b5de565
-	.8byte	0x3ffa5503b23e255d
-	.8byte	0x3ffa9e6b5579fdbf
-	.8byte	0x3ffae89f995ad3ad
-	.8byte	0x3ffb33a2b84f15fb
-	.8byte	0x3ffb7f76f2fb5e47
-	.8byte	0x3ffbcc1e904bc1d2
-	.8byte	0x3ffc199bdd85529c
-	.8byte	0x3ffc67f12e57d14b
-	.8byte	0x3ffcb720dcef9069
-	.8byte	0x3ffd072d4a07897c
-	.8byte	0x3ffd5818dcfba487
-	.8byte	0x3ffda9e603db3285
-	.8byte	0x3ffdfc97337b9b5f
-	.8byte	0x3ffe502ee78b3ff6
-	.8byte	0x3ffea4afa2a490da
-	.8byte	0x3ffefa1bee615a27
-	.8byte	0x3fff50765b6e4540
-	.8byte	0x3fffa7c1819e90d8
-
-.KLN2:
-	.8byte	0x40571547652b82fe	/* Double precision K/log(2).  */
-
-/* Double precision polynomial coefficients.  */
-.P0:
-	.8byte	0x3fefffffffffe7c6
-.P1:
-	.8byte	0x3fe00000008d6118
-.P2:
-	.8byte	0x3fc55550da752d4f
-.P3:
-	.8byte	0x3fa56420eb78fa85
-
-.RS:
-	.8byte	0x4168000000000000	/* Double precision 2^23 + 2^22.  */
-.NLN2K:
-	.8byte	0xbf862e42fefa39ef	/* Double precision -log(2)/K.  */
-.DP_EXP_BIAS:
-	.8byte	0x000000000000ffc0	/* Double precision exponent bias.  */
-
-	.balign	4
-.SPone:
-	.4byte	0x3f800000	/* Single precision 1.0.  */
-.SP_RS:
-	.4byte	0x4b400000	/* Single precision 2^23 + 2^22.  */
-
-.SPRANGE: /* Single precision overflow/underflow bounds.  */
-	.4byte	0x42b17217	/* if x>this bound, then result overflows.  */
-	.4byte	0x42cff1b4	/* if x<this bound, then result underflows.  */
-
-.SPLARGE_SMALL:
-	.4byte	0x71800000	/* 2^100.  */
-	.4byte	0x0d800000	/* 2^-100.  */
-
-.INF_ZERO:
-	.4byte	0x7f800000	/* Single precision Inf.  */
-	.4byte	0		/* Single precision zero.  */
-
-strong_alias (__ieee754_expf, __expf_finite)
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c b/sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c
deleted file mode 100644
index b5fe164520..0000000000
--- a/sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/../math/w_expf.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 23/28] benchtests: hypot benchmark
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (21 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 22/28] powerpc: Use generic e_expf Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-06-26 19:58   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 24/28] powerpc: hypot refactor and optimization Adhemerval Zanella
                   ` (4 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

Inputs are based on argument reductions from generic and powerpc
implementation.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* benchtests/Makefile (bench-math): Add hypot.
	* benchtests/hypot-inputs: New file.
---
 benchtests/Makefile     |  2 +-
 benchtests/hypot-inputs | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 benchtests/hypot-inputs

diff --git a/benchtests/Makefile b/benchtests/Makefile
index 42bf13b27f..013653588e 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -24,7 +24,7 @@ include ../Makeconfig
 bench-math := acos acosh asin asinh atan atanh cos cosh exp exp2 log log2 \
 	      modf pow rint sin sincos sinh sqrt tan tanh fmin fmax fminf \
 	      fmaxf powf trunc truncf expf exp2f logf log2f sincosf sinf \
-	      cosf isnan isinf isfinite
+	      cosf isnan isinf isfinite hypot
 
 bench-pthread := pthread_once thread_create
 
diff --git a/benchtests/hypot-inputs b/benchtests/hypot-inputs
new file mode 100644
index 0000000000..e987e5dd1b
--- /dev/null
+++ b/benchtests/hypot-inputs
@@ -0,0 +1,16 @@
+## includes: math.h
+## args: double:double
+## ret: double
+
+## name: overflow
+0x3.ffffffffffffcp-1024, 0x8p-152
+## name: higher_two500
+0x1.000002027941dp+500,  0x1.0000000000001p+500
+## name: subnormal
+0x0.fffffffffffffp-1022, 0x0.fffffffffffffp-1022
+## name: less_two500
+0x1.fffffffffffffp-501,  0x1.fffffffffffffp-501
+
+## name: default
+3.0                   , 4.0
+5.0                   , 4.0
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 24/28] powerpc: hypot refactor and optimization
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (22 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 23/28] benchtests: hypot benchmark Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-04-01 20:14   ` Joseph Myers
  2019-06-26 19:59   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 25/28] powerpc: Refactor modf{f} Adhemerval Zanella
                   ` (3 subsequent siblings)
  27 siblings, 2 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

The powerpc hypot is slight optimized by:

  - Commit 8df4e219e43, both isnan and isinf are always inlined and thus
    the check TEST_INF_NAN does not make sense anymore.  The generic
    check for POWER7 should be faster on all powerpc configuration.

  - Two reduntant checks (for y == 0 and y > two60factor && (x / y) > two60)
    are removed.

Both changes leads to unrequired ifunc especialization for power7 and
thus they are removed.  Finally The code is also cleanup a bit by inlining
the constants floating points.

The performance changes using the hypot benchtests are:

  - POWER9 without patch:
    "hypot": {
     "overflow": {
      "duration": 4.98585e+09,
      "iterations": 4.84932e+08,
      "max": 46.551,
      "min": 10.229,
      "mean": 10.2815
     },
     "higher_two500": {
      "duration": 5.00192e+09,
      "iterations": 4.24843e+08,
      "max": 33.319,
      "min": 11.606,
      "mean": 11.7736
     },
     "subnormal": {
      "duration": 5.0075e+09,
      "iterations": 4.06792e+08,
      "max": 22.178,
      "min": 12.15,
      "mean": 12.3097
     },
     "less_two500": {
      "duration": 5.00685e+09,
      "iterations": 4.08772e+08,
      "max": 22.784,
      "min": 12.052,
      "mean": 12.2485
     },
     "default": {
      "duration": 5.06002e+09,
      "iterations": 4.09894e+08,
      "max": 20.648,
      "min": 11.874,
      "mean": 12.3447
     }
    }

  - POWER9 with patch:
    "hypot": {
     "overflow": {
      "duration": 4.91848e+09,
      "iterations": 7.28039e+08,
      "max": 47.958,
      "min": 6.436,
      "mean": 6.75579
     },
     "higher_two500": {
      "duration": 4.9359e+09,
      "iterations": 6.63376e+08,
      "max": 20.783,
      "min": 7.321,
      "mean": 7.44057
     },
     "subnormal": {
      "duration": 4.9479e+09,
      "iterations": 6.19772e+08,
      "max": 18.856,
      "min": 7.817,
      "mean": 7.98341
     },
     "less_two500": {
      "duration": 4.94275e+09,
      "iterations": 6.3889e+08,
      "max": 17.452,
      "min": 7.597,
      "mean": 7.73647
     },
     "default": {
      "duration": 5.03645e+09,
      "iterations": 5.70718e+08,
      "max": 18.904,
      "min": 8.55,
      "mean": 8.82476
     }
    }

  - POWER7 without patch
    "hypot": {
     "overflow": {
      "duration": 4.86637e+09,
      "iterations": 6.43196e+08,
      "max": 53.958,
      "min": 7.328,
      "mean": 7.56592
     },
     "higher_two500": {
      "duration": 4.99842e+09,
      "iterations": 3.11012e+08,
      "max": 78.227,
      "min": 15.696,
      "mean": 16.0715
     },
     "subnormal": {
      "duration": 4.99841e+09,
      "iterations": 3.08935e+08,
      "max": 51.392,
      "min": 15.983,
      "mean": 16.1795
     },
     "less_two500": {
      "duration": 5.00108e+09,
      "iterations": 2.99464e+08,
      "max": 73.247,
      "min": 16.416,
      "mean": 16.7001
     },
     "default": {
      "duration": 5.04645e+09,
      "iterations": 3.52608e+08,
      "max": 70.073,
      "min": 13.38,
      "mean": 14.3118
     }
    }

  - POWER7 with patch
    "hypot": {
     "overflow": {
      "duration": 4.80785e+09,
      "iterations": 8.00001e+08,
      "max": 66.262,
      "min": 5.888,
      "mean": 6.00981
     },
     "higher_two500": {
      "duration": 4.9859e+09,
      "iterations": 3.39449e+08,
      "max": 5148.44,
      "min": 14.539,
      "mean": 14.6882
     },
     "subnormal": {
      "duration": 4.9905e+09,
      "iterations": 3.28874e+08,
      "max": 64.905,
      "min": 14.971,
      "mean": 15.1745
     },
     "less_two500": {
      "duration": 4.99494e+09,
      "iterations": 3.19755e+08,
      "max": 103.696,
      "min": 14.972,
      "mean": 15.6211
     },
     "default": {
      "duration": 5.03951e+09,
      "iterations": 4.02502e+08,
      "max": 61.008,
      "min": 12.368,
      "mean": 12.5205
     }
    }

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/fpu/e_hypot.c (two60, two500, two600, two1022,
	twoM500, twoM600, two60factor, pdnum): Remove.
	(TEST_INFO_NAN): Remove macro.
	(__ieee754_hypot): Replace static variables with inline definition,
	remove ununsed branches.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Remove e_hypot-* objects.
	(CFLAGS-e_hypot-power7.c, CFLAGS-e_hypotf-power7.c): Remove rule.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c: Remove
	file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c: Likewise.
---
 sysdeps/powerpc/fpu/e_hypot.c                 | 96 +++++--------------
 .../powerpc/powerpc64/fpu/multiarch/Makefile  |  5 +-
 .../powerpc64/fpu/multiarch/e_hypot-power7.c  | 19 ----
 .../powerpc64/fpu/multiarch/e_hypot-ppc64.c   | 26 -----
 .../powerpc/powerpc64/fpu/multiarch/e_hypot.c | 33 -------
 .../powerpc64/fpu/multiarch/e_hypotf-power7.c | 19 ----
 .../powerpc64/fpu/multiarch/e_hypotf-ppc64.c  | 26 -----
 .../powerpc64/fpu/multiarch/e_hypotf.c        | 33 -------
 8 files changed, 23 insertions(+), 234 deletions(-)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c

diff --git a/sysdeps/powerpc/fpu/e_hypot.c b/sysdeps/powerpc/fpu/e_hypot.c
index 039e5be430..adbc7d28f6 100644
--- a/sysdeps/powerpc/fpu/e_hypot.c
+++ b/sysdeps/powerpc/fpu/e_hypot.c
@@ -22,15 +22,6 @@
 #include <math-underflow.h>
 #include <stdint.h>
 
-static const double two60   = 1.152921504606847e+18;
-static const double two500  = 3.2733906078961419e+150;
-static const double two600  = 4.149515568880993e+180;
-static const double two1022 = 4.49423283715579e+307;
-static const double twoM500 = 3.054936363499605e-151;
-static const double twoM600 = 2.4099198651028841e-181;
-static const double two60factor = 1.5592502418239997e+290;
-static const double pdnum   = 2.225073858507201e-308;
-
 /* __ieee754_hypot(x,y)
  *
  * This a FP only version without any FP->INT conversion.
@@ -39,95 +30,52 @@ static const double pdnum   = 2.225073858507201e-308;
  * is needed.
  */
 
-#ifdef _ARCH_PWR7
-/* POWER7 isinf and isnan optimization are fast. */
-# define TEST_INF_NAN(x, y)                                       \
-   if ((isinf(x) || isinf(y))					  \
-       && !issignaling (x) && !issignaling (y))			  \
-       return INFINITY;                                           \
-   if (isnan(x) || isnan(y))                                      \
-       return x + y;
-# else
-/* For POWER6 and below isinf/isnan triggers LHS and PLT calls are
- * costly (especially for POWER6). */
-# define GET_TW0_HIGH_WORD(d1,d2,i1,i2)                           \
- do {                                                             \
-   ieee_double_shape_type gh_u1;                                  \
-   ieee_double_shape_type gh_u2;                                  \
-   gh_u1.value = (d1);                                            \
-   gh_u2.value = (d2);                                            \
-   (i1) = gh_u1.parts.msw & 0x7fffffff;                           \
-   (i2) = gh_u2.parts.msw & 0x7fffffff;                           \
- } while (0)
-
-# define TEST_INF_NAN(x, y)                                      \
- do {                                                            \
-   uint32_t hx, hy;                                              \
-   GET_TW0_HIGH_WORD(x, y, hx, hy);                              \
-   if (hy > hx) {                                                \
-     uint32_t ht = hx; hx = hy; hy = ht;                         \
-   }                                                             \
-   if (hx >= 0x7ff00000) {                                       \
-     if ((hx == 0x7ff00000 || hy == 0x7ff00000)			 \
-	 && !issignaling (x) && !issignaling (y))		 \
-       return INFINITY;                                          \
-     return x + y;						 \
-   }                                                             \
- } while (0)
-
-#endif
-
-
 double
 __ieee754_hypot (double x, double y)
 {
+  if ((isinf(x) || isinf(y))
+      && !issignaling (x) && !issignaling (y))
+    return INFINITY;
+  if (isnan(x) || isnan(y))
+    return x + y;
+
   x = fabs (x);
   y = fabs (y);
 
-  TEST_INF_NAN (x, y);
-
   if (y > x)
     {
       double t = x;
       x = y;
       y = t;
     }
-  if (y == 0.0)
-    return x;
+
   /* if y is higher enough, y * 2^60 might overflow. The tests if
      y >= 1.7976931348623157e+308/2^60 (two60factor) and uses the
      appropriate check to avoid the overflow exception generation.  */
-  if (y > two60factor)
-    {
-      if ((x / y) > two60)
-	return x + y;
-    }
-  else
-    {
-      if (x > (y * two60))
-	return x + y;
-    }
-  if (x > two500)
+  if (y <= 0x1.fffffffffffffp+963 && x > (y * 0x1p+60))
+    return x + y;
+
+  if (x > 0x1p+500)
     {
-      x *= twoM600;
-      y *= twoM600;
-      return sqrt (x * x + y * y) / twoM600;
+      x *= 0x1p-600;
+      y *= 0x1p-600;
+      return sqrt (x * x + y * y) / 0x1p-600;
     }
-  if (y < twoM500)
+  if (y < 0x1p-500)
     {
-      if (y <= pdnum)
+      if (y <= 0x0.fffffffffffffp-1022)
 	{
-	  x *= two1022;
-	  y *= two1022;
-	  double ret = sqrt (x * x + y * y) / two1022;
+	  x *= 0x1p+1022;
+	  y *= 0x1p+1022;
+	  double ret = sqrt (x * x + y * y) / 0x1p+1022;
 	  math_check_force_underflow_nonneg (ret);
 	  return ret;
 	}
       else
 	{
-	  x *= two600;
-	  y *= two600;
-	  return sqrt (x * x + y * y) / two600;
+	  x *= 0x1p+600;
+	  y *= 0x1p+600;
+	  return sqrt (x * x + y * y) / 0x1p+600;
 	}
     }
   return sqrt (x * x + y * y);
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 118865a1a9..534d5a7133 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -8,8 +8,7 @@ sysdep_calls := s_modf-power5+ s_modf-ppc64 \
 sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_logb-power7 s_logbf-power7 \
 			s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
-			s_logbl-ppc64 e_hypot-ppc64 \
-			e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
+			s_logbl-ppc64 \
 			$(sysdep_calls:s_%=m_%)
 
 CFLAGS-s_logbf-power7.c = -mcpu=power7
@@ -17,8 +16,6 @@ CFLAGS-s_logbl-power7.c = -mcpu=power7
 CFLAGS-s_logb-power7.c = -mcpu=power7
 CFLAGS-s_modf-power5+.c = -mcpu=power5+
 CFLAGS-s_modff-power5+.c = -mcpu=power5+
-CFLAGS-e_hypot-power7.c = -mcpu=power7
-CFLAGS-e_hypotf-power7.c = -mcpu=power7
 
 # These files quiet sNaNs in a way that is optimized away without
 # -fsignaling-nans.
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c
deleted file mode 100644
index 69818d8438..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ieee_hypot() POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/e_hypot-power7.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c
deleted file mode 100644
index da1e80f0d6..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ieee_hypot() PowerPC64 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define __ieee754_hypot __ieee754_hypot_ppc64
-
-#include <sysdeps/powerpc/fpu/e_hypot.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c
deleted file mode 100644
index 3bd04e9517..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Multiple versions of ieee754_hypot.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math_private.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__ieee754_hypot) __ieee754_hypot_ppc64 attribute_hidden;
-extern __typeof (__ieee754_hypot) __ieee754_hypot_power7 attribute_hidden;
-
-libc_ifunc (__ieee754_hypot,
-	    (hwcap & PPC_FEATURE_ARCH_2_06)
-	    ? __ieee754_hypot_power7
-            : __ieee754_hypot_ppc64);
-
-strong_alias (__ieee754_hypot, __hypot_finite)
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c
deleted file mode 100644
index 223947a617..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ieee_hypotf() POWER7 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/e_hypotf-power7.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c
deleted file mode 100644
index 6d5d54bb79..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ieee_hypot() PowerPC64 version.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define __ieee754_hypotf __ieee754_hypotf_ppc64
-
-#include <sysdeps/powerpc/fpu/e_hypotf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c
deleted file mode 100644
index 02c0ab497f..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Multiple versions of ieee754_hypot.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math_private.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__ieee754_hypotf) __ieee754_hypotf_ppc64 attribute_hidden;
-extern __typeof (__ieee754_hypotf) __ieee754_hypotf_power7 attribute_hidden;
-
-libc_ifunc (__ieee754_hypotf,
-	    (hwcap & PPC_FEATURE_ARCH_2_06)
-	    ? __ieee754_hypotf_power7
-            : __ieee754_hypotf_ppc64);
-
-strong_alias (__ieee754_hypotf, __hypotf_finite)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 25/28] powerpc: Refactor modf{f}
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (23 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 24/28] powerpc: hypot refactor and optimization Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-07-05  1:23   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 26/28] benchtests: Add logb{f} benchmark Adhemerval Zanella
                   ` (2 subsequent siblings)
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

The modf{f} optimization is not an optimization for ISA 2.07+.  This
patch move the IFUNC for powerpc64 only, move the power5+ to generic
location, and include the generic implementation for ISA 2.07+.

The performance changes are based on modf benchtests:

  * POWER9 - generic code
  "modf": {
   "": {
    "duration": 4.97057e+09,
    "iterations": 1.00688e+09,
    "max": 28.76,
    "min": 4.912,
    "mean": 4.9366
   }
  }
  * POWER9 - power5+ optimization
  "modf": {
   "": {
    "duration": 4.98291e+09,
    "iterations": 9.32818e+08,
    "max": 15.058,
    "min": 5.107,
    "mean": 5.34178
   }
  }

  * POWER8 - generic code
   "modf": {
   "": {
    "duration": 5.05329e+09,
    "iterations": 8.38814e+08,
    "max": 518.051,
    "min": 5.79,
    "mean": 6.02433
   }
  }
  * POWER8 - power5+ optimization
  "modf": {
   "": {
    "duration": 5.05573e+09,
    "iterations": 8.35254e+08,
    "max": 63.141,
    "min": 5.873,
    "mean": 6.05293
   }
  }

  * POWER7 - generic code
  "modf": {
   "": {
    "duration": 4.89818e+09,
    "iterations": 1.08408e+09,
    "max": 57.556,
    "min": 3.953,
    "mean": 4.51827
   }
  }
  * POWER7 - power5+ optimization
  "modf": {
   "": {
    "duration": 4.83789e+09,
    "iterations": 1.33409e+09,
    "max": 46.608,
    "min": 2.224,
    "mean": 3.62636
   }
  }

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/power5+/fpu/s_modf.c: Move to ...
	* sysdeps/powerpc/fpu/s_modf.c: ... here.  Add ISA 2.07 optimization.
	* sysdeps/powerpc/power5+/fpu/s_modff.c: Move to ...
	* sysdeps/powerpc/fpu/s_modff.c: ... here.  Add ISA 2.07 optimization.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c:
	Adjust include.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile (sysdep_calls,
	sysdep_routines): Add s_modf* objects.
	(CFLAGS-s_modf-power5+.c, CFLAGS-s_modff-power5+.c,
	CFLAGS-s_modf-ppc64.c, CFLAGS-s_modff-ppc64.c): New rule.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf-power5+.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf-power5+.c: Movo
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c: Move
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff-power5+.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff-ppc64.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-ppc64.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff.c: ... here.
---
 sysdeps/powerpc/{power5+ => }/fpu/s_modf.c    | 17 +++++++++++++----
 sysdeps/powerpc/{power5+ => }/fpu/s_modff.c   | 13 +++++++++++--
 .../power4/fpu/multiarch/s_modf-power5+.c     | 13 +------------
 .../power4/fpu/multiarch/s_modff-power5+.c    |  9 +--------
 .../powerpc64/be/fpu/multiarch/Makefile       | 19 ++++++++++++++++++-
 .../{ => be}/fpu/multiarch/s_modf-power5+.c   |  3 ++-
 .../{ => be}/fpu/multiarch/s_modf-ppc64.c     |  0
 .../powerpc64/{ => be}/fpu/multiarch/s_modf.c |  0
 .../{ => be}/fpu/multiarch/s_modff-power5+.c  |  3 ++-
 .../{ => be}/fpu/multiarch/s_modff-ppc64.c    |  0
 .../{ => be}/fpu/multiarch/s_modff.c          |  0
 .../powerpc/powerpc64/fpu/multiarch/Makefile  | 13 -------------
 12 files changed, 48 insertions(+), 42 deletions(-)
 rename sysdeps/powerpc/{power5+ => }/fpu/s_modf.c (74%)
 rename sysdeps/powerpc/{power5+ => }/fpu/s_modff.c (77%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modf-power5+.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modf-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modf.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modff-power5+.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modff-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_modff.c (100%)

diff --git a/sysdeps/powerpc/power5+/fpu/s_modf.c b/sysdeps/powerpc/fpu/s_modf.c
similarity index 74%
rename from sysdeps/powerpc/power5+/fpu/s_modf.c
rename to sysdeps/powerpc/fpu/s_modf.c
index dbb11652e1..2304fc48ed 100644
--- a/sysdeps/powerpc/power5+/fpu/s_modf.c
+++ b/sysdeps/powerpc/fpu/s_modf.c
@@ -15,9 +15,15 @@
    License along with the GNU C Library; see the file COPYING.LIB.  If
    not, see <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
+/* ISA 2.07 provides fast GPR to FP instruction (mfvsr{d,wz}) which make
+   generic implementation faster.  Also disables for old ISAs that do not
+   have ceil/floor instructions.  */
+#if defined(_ARCH_PWR8) || !defined(_ARCH_PWR5X)
+# include <sysdeps/ieee754/ldbl-opt/s_modf.c>
+#else
+# include <math.h>
+# include <math_ldbl_opt.h>
+# include <libm-alias-double.h>
 
 double
 __modf (double x, double *iptr)
@@ -44,7 +50,10 @@ __modf (double x, double *iptr)
       return copysign (x - *iptr, x);
     }
 }
+# ifndef __modf
 libm_alias_double (__modf, modf)
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+#  if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
 compat_symbol (libc, __modf, modfl, GLIBC_2_0);
+#  endif
+# endif
 #endif
diff --git a/sysdeps/powerpc/power5+/fpu/s_modff.c b/sysdeps/powerpc/fpu/s_modff.c
similarity index 77%
rename from sysdeps/powerpc/power5+/fpu/s_modff.c
rename to sysdeps/powerpc/fpu/s_modff.c
index 87c9f020f7..2a0f114b20 100644
--- a/sysdeps/powerpc/power5+/fpu/s_modff.c
+++ b/sysdeps/powerpc/fpu/s_modff.c
@@ -15,8 +15,14 @@
    License along with the GNU C Library; see the file COPYING.LIB.  If
    not, see <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <libm-alias-float.h>
+/* ISA 2.07 provides fast GPR to FP instruction (mfvsr{d,wz}) which make
+   generic implementation faster.  Also disables for old ISAs that do not
+   have ceil/floor instructions.  */
+#if defined(_ARCH_PWR8) || !defined(_ARCH_PWR5X)
+# include <sysdeps/ieee754/flt-32/s_modff.c>
+#else
+# include <math.h>
+# include <libm-alias-float.h>
 
 float
 __modff (float x, float *iptr)
@@ -43,4 +49,7 @@ __modff (float x, float *iptr)
       return copysignf (x - *iptr, x);
     }
 }
+# ifndef __modff
 libm_alias_float (__modf, modf)
+# endif
+#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c
index b1d0540b31..6f93c2b652 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c
@@ -16,16 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-#undef strong_alias
-#define strong_alias(a,b)
-#undef compat_symbol
-#define compat_symbol(a,b,c,d)
-
 #define __modf __modf_power5plus
-
-#include <sysdeps/powerpc/power5+/fpu/s_modf.c>
+#include <sysdeps/powerpc/fpu/s_modf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c
index 8b333eae0d..2e701881e8 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c
@@ -16,12 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a,b)
-
 #define __modff __modff_power5plus
-
-#include <sysdeps/powerpc/power5+/fpu/s_modff.c>
+#include <sysdeps/powerpc/fpu/s_modff.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index 9917cd15d5..63de39bbf1 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -1,4 +1,13 @@
 ifeq ($(subdir),math)
+# These functions are built both for libc and libm because they're required
+# by printf.  While the libc objects have the prefix s_, the libm ones are
+# prefixed with  m_.
+sysdep_calls := s_modf-power5+ \
+		s_modf-ppc64 \
+		s_modff-power5+ \
+		s_modff-ppc64
+
+sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_ceil-power5+ \
 			s_ceil-ppc64 \
 			s_ceilf-power5+ \
@@ -22,7 +31,8 @@ libm-sysdep_routines += s_ceil-power5+ \
 			s_llround-power6x \
 			s_llround-power5+ \
 			s_llround-ppc64 \
-			s_llroundf-ppc64
+			s_llroundf-ppc64 \
+			$(sysdep_calls:s_%=m_%)
 
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
 CFLAGS-s_ceilf-power5+.c = -mcpu=power5+
@@ -35,4 +45,11 @@ CFLAGS-s_truncf-power5+.c = -mcpu=power5+
 CFLAGS-s_llround-power8.c += -mcpu=power8
 CFLAGS-s_llround-power6x.c += -mcpu=power6x
 CFLAGS-s_llround-power5+.c += -mcpu=power5+
+
+CFLAGS-s_modf-power5+.c += -mcpu=power5+
+CFLAGS-s_modff-power5+.c += -mcpu=power5+
+# These files quiet sNaNs in a way that is optimized away without
+# -fsignaling-nans.
+CFLAGS-s_modf-ppc64.c += -fsignaling-nans
+CFLAGS-s_modff-ppc64.c += -fsignaling-nans
 endif
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c
similarity index 91%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf-power5+.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c
index 1a958de178..6f93c2b652 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf-power5+.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-power5+.c
@@ -16,4 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf-power5+.c>
+#define __modf __modf_power5plus
+#include <sysdeps/powerpc/fpu/s_modf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-ppc64.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf-ppc64.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf-ppc64.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modf.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c
similarity index 91%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff-power5+.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c
index 4939d4bc2b..2e701881e8 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff-power5+.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-power5+.c
@@ -16,4 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff-power5+.c>
+#define __modff __modff_power5plus
+#include <sysdeps/powerpc/fpu/s_modff.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-ppc64.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff-ppc64.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff-ppc64.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_modff.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 534d5a7133..d7ad1e2724 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -1,10 +1,4 @@
 ifeq ($(subdir),math)
-# These functions are built both for libc and libm because they're required
-# by printf.  While the libc objects have the prefix s_, the libm ones are
-# prefixed with  m_.
-sysdep_calls := s_modf-power5+ s_modf-ppc64 \
-		s_modff-power5+ s_modff-ppc64
-
 sysdep_routines += $(sysdep_calls)
 libm-sysdep_routines += s_logb-power7 s_logbf-power7 \
 			s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
@@ -14,11 +8,4 @@ libm-sysdep_routines += s_logb-power7 s_logbf-power7 \
 CFLAGS-s_logbf-power7.c = -mcpu=power7
 CFLAGS-s_logbl-power7.c = -mcpu=power7
 CFLAGS-s_logb-power7.c = -mcpu=power7
-CFLAGS-s_modf-power5+.c = -mcpu=power5+
-CFLAGS-s_modff-power5+.c = -mcpu=power5+
-
-# These files quiet sNaNs in a way that is optimized away without
-# -fsignaling-nans.
-CFLAGS-s_modf-ppc64.c += -fsignaling-nans
-CFLAGS-s_modff-ppc64.c += -fsignaling-nans
 endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 26/28] benchtests: Add logb{f} benchmark
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (24 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 25/28] powerpc: Refactor modf{f} Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-07-05  1:23   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 27/28] math: Use wordsize-64 version for s_logb Adhemerval Zanella
  2019-03-29 13:35 ` [PATCH 28/28] powerpc: refactor logb{f,l} Adhemerval Zanella
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* benchtests/Makefile (bench-math): Add logb.
	* benchtests/logb-inputs: New file.
	* benchtests/logbf-inputs: New file.
---
 benchtests/Makefile     |  2 +-
 benchtests/logb-inputs  | 11 +++++++++++
 benchtests/logbf-inputs | 11 +++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 benchtests/logb-inputs
 create mode 100644 benchtests/logbf-inputs

diff --git a/benchtests/Makefile b/benchtests/Makefile
index 013653588e..07343b01c6 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -24,7 +24,7 @@ include ../Makeconfig
 bench-math := acos acosh asin asinh atan atanh cos cosh exp exp2 log log2 \
 	      modf pow rint sin sincos sinh sqrt tan tanh fmin fmax fminf \
 	      fmaxf powf trunc truncf expf exp2f logf log2f sincosf sinf \
-	      cosf isnan isinf isfinite hypot
+	      cosf isnan isinf isfinite hypot logb logbf
 
 bench-pthread := pthread_once thread_create
 
diff --git a/benchtests/logb-inputs b/benchtests/logb-inputs
new file mode 100644
index 0000000000..ab3b161696
--- /dev/null
+++ b/benchtests/logb-inputs
@@ -0,0 +1,11 @@
+## args: double
+## ret: double
+## includes: math.h
+
+## name: subnormal
+0x0.0000000000001p-1022
+0x0.fffffffffffffp-1022
+
+## name: normal
+1.0
+1024.0
diff --git a/benchtests/logbf-inputs b/benchtests/logbf-inputs
new file mode 100644
index 0000000000..c97fa17842
--- /dev/null
+++ b/benchtests/logbf-inputs
@@ -0,0 +1,11 @@
+## args: double
+## ret: double
+## includes: math.h
+
+## name: subnormal
+0x1p-149
+0x1.fffff8p-128
+
+## name: normal
+1.0
+1024.0
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 27/28] math: Use wordsize-64 version for s_logb
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (25 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 26/28] benchtests: Add logb{f} benchmark Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-07-05  1:23   ` Gabriel F. T. Gomes
  2019-03-29 13:35 ` [PATCH 28/28] powerpc: refactor logb{f,l} Adhemerval Zanella
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

  - The resulting binary difference on 32 bits architecture is
    minimum.  On i686-linux-gnu (with architecture optimization
    routine removed) there is no different using logb benchtests

  - It helps wordsize-64 architectures that use ldbl-opt.

  - It add some code simplification with reduction of duplicated
    implementations.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c: Move to ...
	* sysdeps/ieee754/dbl-64/s_logb.c: ... here.  Add work around for
	powerpc32 integer 0 converting to -0.
---
 sysdeps/ieee754/dbl-64/s_logb.c             | 61 ++++++++++-----------
 sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c | 47 ----------------
 2 files changed, 29 insertions(+), 79 deletions(-)
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c

diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c
index a6de1f6e49..e336251fda 100644
--- a/sysdeps/ieee754/dbl-64/s_logb.c
+++ b/sysdeps/ieee754/dbl-64/s_logb.c
@@ -1,22 +1,24 @@
-/* @(#)s_logb.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+/* Compute radix independent exponent.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
 
-/*
- * double logb(x)
- * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
- * Use ilogb instead.
- */
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+
 #include <math_private.h>
 #include <libm-alias-double.h>
 #include <fix-int-fp-convert-zero.h>
@@ -24,28 +26,23 @@
 double
 __logb (double x)
 {
-  int32_t lx, ix, rix;
+  int64_t ix, ex;
 
-  EXTRACT_WORDS (ix, lx, x);
-  ix &= 0x7fffffff;             /* high |x| */
-  if ((ix | lx) == 0)
+  EXTRACT_WORDS64 (ix, x);
+  ix &= UINT64_C(0x7fffffffffffffff);
+  if (ix == 0)
     return -1.0 / fabs (x);
-  if (ix >= 0x7ff00000)
+  ex = ix >> 52;
+  if (ex == 0x7ff)
     return x * x;
-  if (__glibc_unlikely ((rix = ix >> 20) == 0))
+  if (__glibc_unlikely (ex == 0))
     {
-      /* POSIX specifies that denormal number is treated as
-         though it were normalized.  */
-      int ma;
-      if (ix == 0)
-	ma = __builtin_clz (lx) + 32;
-      else
-	ma = __builtin_clz (ix);
-      rix -= ma - 12;
+      int m = __builtin_clzll (ix);
+      ex -= m - 12;
     }
-  if (FIX_INT_FP_CONVERT_ZERO && rix == 1023)
+  if (FIX_INT_FP_CONVERT_ZERO && ex == 1023)
     return 0.0;
-  return (double) (rix - 1023);
+  return (double) (ex - 1023);
 }
 #ifndef __logb
 libm_alias_double (__logb, logb)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
deleted file mode 100644
index d9b40af2c7..0000000000
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Compute radix independent exponent.
-   Copyright (C) 2011-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#include <math_private.h>
-#include <libm-alias-double.h>
-
-
-double
-__logb (double x)
-{
-  int64_t ix, ex;
-
-  EXTRACT_WORDS64 (ix, x);
-  ix &= UINT64_C(0x7fffffffffffffff);
-  if (ix == 0)
-    return -1.0 / fabs (x);
-  ex = ix >> 52;
-  if (ex == 0x7ff)
-    return x * x;
-  if (__glibc_unlikely (ex == 0))
-    {
-      int m = __builtin_clzll (ix);
-      ex -= m - 12;
-    }
-  return (double) (ex - 1023);
-}
-#ifndef __logb
-libm_alias_double (__logb, logb)
-#endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH 28/28] powerpc: refactor logb{f,l}
  2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
                   ` (26 preceding siblings ...)
  2019-03-29 13:35 ` [PATCH 27/28] math: Use wordsize-64 version for s_logb Adhemerval Zanella
@ 2019-03-29 13:35 ` Adhemerval Zanella
  2019-07-05  1:24   ` Gabriel F. T. Gomes
  27 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha

The power7 logb implementation does not show a performance gain on
ISA 2.07+ chips with faster floating-point to GRP instructions
(currently POWER8 and POWER9).

This patch moves the POWER7 implementation to generic one and enables
it for POWER7.  It also add some cleanup to use inline floating-point
number instead of define them using static const.

The performance difference is for POWER9:

  - Without patch:
  "logb": {
   "subnormal": {
    "duration": 4.99202e+09,
    "iterations": 8.83662e+08,
    "max": 75.194,
    "min": 5.501,
    "mean": 5.64925
   },
   "normal": {
    "duration": 4.97063e+09,
    "iterations": 9.97094e+08,
    "max": 46.489,
    "min": 4.956,
    "mean": 4.98512
   }
  }

  - With patch:
  "logb": {
   "subnormal": {
    "duration": 4.97226e+09,
    "iterations": 9.92036e+08,
    "max": 77.209,
    "min": 4.892,
    "mean": 5.01218
   },
   "normal": {
    "duration": 4.96192e+09,
    "iterations": 1.07545e+09,
    "max": 12.361,
    "min": 4.593,
    "mean": 4.61382
   }
  }

The ifunc implementation is also enabled only for powerpc64.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

	* sysdeps/powerpc/power7/fpu/s_logb.c: Move to ...
	* sysdeps/powerpc/fpu/s_logb.c: ... here.  Use inline FP constants.
	* sysdeps/powerpc/power7/fpu/s_logbf.c: Move to ...
	* sysdeps/powerpc/fpu/s_logbf.c: ... here.  Use inline FP constants.
	* sysdeps/powerpc/power7/fpu/s_logbl.c: Move to ...
	* sysdeps/powerpc/fpu/s_logbl.c: ... here.  Use inline FP constants.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb-power7.c:
	Adjust implementation path.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbf-power7.c:
	Adjust implementation path.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbl-power7.c:
	Adjust implementation path.
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
	(libm-sysdep_routines): Add s_log* objects.
	(CFLAGS-s_logbf-power7.c, CFLAGS-s_logbl-power7.c,
	CFLAGS-s_logb-power7.c): New fule.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb-power7.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb-power7.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb-ppc64.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb-ppc64.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf-power7.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf-power7.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf-ppc64.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf-ppc64.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl-power7.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl-power7.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl-ppc64.c: Move
	to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl-ppc64.c:
	... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl.c: Move to ...
	* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl.c: ... here.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile: Remove file.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c: Remove file.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_logbf.c: Likewise.
	* sysdeps/powerpc/powerpc64/power7/fpu/s_logbl.c: Likewise.
---
 sysdeps/powerpc/{power7 => }/fpu/s_logb.c     | 64 ++++++++-----------
 sysdeps/powerpc/{power7 => }/fpu/s_logbf.c    | 44 ++++++-------
 sysdeps/powerpc/{power7 => }/fpu/s_logbl.c    | 47 ++++++--------
 .../power4/fpu/multiarch/s_logb-power7.c      | 13 +---
 .../power4/fpu/multiarch/s_logbf-power7.c     |  8 +--
 .../power4/fpu/multiarch/s_logbl-power7.c     |  3 +-
 .../powerpc64/be/fpu/multiarch/Makefile       | 10 +++
 .../{ => be}/fpu/multiarch/s_logb-power7.c    |  3 +-
 .../{ => be}/fpu/multiarch/s_logb-ppc64.c     |  0
 .../powerpc64/{ => be}/fpu/multiarch/s_logb.c |  0
 .../{ => be}/fpu/multiarch/s_logbf-power7.c   |  3 +-
 .../{ => be}/fpu/multiarch/s_logbf-ppc64.c    |  0
 .../{ => be}/fpu/multiarch/s_logbf.c          |  0
 .../{ => be}/fpu/multiarch/s_logbl-power7.c   |  3 +-
 .../{ => be}/fpu/multiarch/s_logbl-ppc64.c    |  0
 .../{ => be}/fpu/multiarch/s_logbl.c          |  0
 .../powerpc/powerpc64/fpu/multiarch/Makefile  | 11 ----
 sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c |  1 -
 .../powerpc/powerpc64/power7/fpu/s_logbf.c    |  1 -
 .../powerpc/powerpc64/power7/fpu/s_logbl.c    |  1 -
 20 files changed, 87 insertions(+), 125 deletions(-)
 rename sysdeps/powerpc/{power7 => }/fpu/s_logb.c (56%)
 rename sysdeps/powerpc/{power7 => }/fpu/s_logbf.c (67%)
 rename sysdeps/powerpc/{power7 => }/fpu/s_logbl.c (72%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logb-power7.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logb-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logb.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbf-power7.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbf-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbf.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbl-power7.c (91%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbl-ppc64.c (100%)
 rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_logbl.c (100%)
 delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_logbf.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power7/fpu/s_logbl.c

diff --git a/sysdeps/powerpc/power7/fpu/s_logb.c b/sysdeps/powerpc/fpu/s_logb.c
similarity index 56%
rename from sysdeps/powerpc/power7/fpu/s_logb.c
rename to sysdeps/powerpc/fpu/s_logb.c
index 4cddc0f9c1..364f7f0cc3 100644
--- a/sysdeps/powerpc/power7/fpu/s_logb.c
+++ b/sysdeps/powerpc/fpu/s_logb.c
@@ -1,4 +1,4 @@
-/* logb(). PowerPC/POWER7 version.
+/* Get exponent of a floating-point value.  PowerPC version.
    Copyright (C) 2012-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,59 +16,49 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_private.h>
-#include <math_ldbl_opt.h>
-#include <libm-alias-double.h>
+/* ISA 2.07 provides fast GPR to FP instruction (mfvsr{d,wz}) which make
+   generic implementation faster.  */
+#if defined(_ARCH_PWR8) || !defined(_ARCH_PWR7)
+# include <sysdeps/ieee754/dbl-64/s_logb.c>
+#else
+# include <math.h>
+# include <math_private.h>
+# include <math_ldbl_opt.h>
+# include <libm-alias-double.h>
 
 /* This implementation avoids FP to INT conversions by using VSX
    bitwise instructions over FP values.  */
-
-static const double two1div52 = 2.220446049250313e-16;	/* 1/2**52  */
-static const double two10m1   = -1023.0;		/* 2**10 -1  */
-
-/* FP mask to extract the exponent.  */
-static const union {
-  unsigned long long mask;
-  double d;
-} mask = { 0x7ff0000000000000ULL };
-
 double
 __logb (double x)
 {
   double ret;
 
-  if (__builtin_expect (x == 0.0, 0))
+  if (__glibc_unlikely (x == 0.0))
     /* Raise FE_DIVBYZERO and return -HUGE_VAL[LF].  */
-    return -1.0 / __builtin_fabs (x);
+    return -1.0 / fabs (x);
 
-  /* ret = x & 0x7ff0000000000000;  */
-  asm (
-    "xxland %x0,%x1,%x2\n"
-    "fcfid  %0,%0"
-    : "=f" (ret)
-    : "f" (x), "f" (mask.d));
-  /* ret = (ret >> 52) - 1023.0;  */
-  ret = (ret * two1div52) + two10m1;
-  if (__builtin_expect (ret > -two10m1, 0))
+  /* Mask to extract the exponent.  */
+  asm ("xxland %x0,%x1,%x2\n"
+       "fcfid  %0,%0"
+       : "=d" (ret)
+       : "d" (x), "d" (0x7ff0000000000000ULL));
+  ret = (ret * 0x1p-52) - 1023.0;
+  if (ret > 1023.0)
     /* Multiplication is used to set logb (+-INF) = INF.  */
     return (x * x);
-  else if (__builtin_expect (ret == two10m1, 0))
+  else if (ret == -1023.0)
     {
       /* POSIX specifies that denormal numbers are treated as
          though they were normalized.  */
-      int32_t lx, ix;
-      int ma;
-
-      EXTRACT_WORDS (ix, lx, x);
-      ix &= 0x7fffffff;
-      if (ix == 0)
-	ma = __builtin_clz (lx) + 32;
-      else
-	ma = __builtin_clz (ix);
-      return (double) (-1023 - (ma - 12));
+      int64_t ix;
+      EXTRACT_WORDS64 (ix, x);
+      ix &= UINT64_C (0x7fffffffffffffff);
+      return (double) (-1023 - (__builtin_clzll (ix) - 12));
     }
   /* Test to avoid logb_downward (0.0) == -0.0.  */
   return ret == -0.0 ? 0.0 : ret;
 }
+# ifndef __logb
 libm_alias_double (__logb, logb)
+# endif
+#endif
diff --git a/sysdeps/powerpc/power7/fpu/s_logbf.c b/sysdeps/powerpc/fpu/s_logbf.c
similarity index 67%
rename from sysdeps/powerpc/power7/fpu/s_logbf.c
rename to sysdeps/powerpc/fpu/s_logbf.c
index b0d006b5c7..cf564ad294 100644
--- a/sysdeps/powerpc/power7/fpu/s_logbf.c
+++ b/sysdeps/powerpc/fpu/s_logbf.c
@@ -1,4 +1,4 @@
-/* logbf(). PowerPC/POWER7 version.
+/* Get exponent of a floating-point value.  PowerPC version.
    Copyright (C) 2012-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,40 +16,33 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <libm-alias-float.h>
-
+/* ISA 2.07 provides fast GPR to FP instruction (mfvsr{d,wz}) which make
+   generic implementation faster.  */
+#if defined(_ARCH_PWR8) || !defined(_ARCH_PWR7)
+# include <sysdeps/ieee754/flt-32/s_logbf.c>
+#else
+# include <math.h>
+# include <libm-alias-float.h>
 /* This implementation avoids FP to INT conversions by using VSX
    bitwise instructions over FP values.  */
-
-static const double two1div52 = 2.220446049250313e-16;	/* 1/2**52  */
-static const double two10m1   = -1023.0;		/* -2**10 + 1  */
-static const double two7m1    = -127.0;			/* -2**7 + 1  */
-
-/* FP mask to extract the exponent.  */
-static const union {
-  unsigned long long mask;
-  double d;
-} mask = { 0x7ff0000000000000ULL };
-
 float
 __logbf (float x)
 {
   /* VSX operation are all done internally as double.  */
   double ret;
 
-  if (__builtin_expect (x == 0.0, 0))
+  if (__glibc_unlikely (x == 0.0))
     /* Raise FE_DIVBYZERO and return -HUGE_VAL[LF].  */
-    return -1.0 / __builtin_fabsf (x);
+    return -1.0 / fabs (x);
 
-  /* ret = x & 0x7f800000;  */
-  asm (
-    "xxland %x0,%x1,%x2\n"
-    "fcfid  %0,%0"
-    : "=f"(ret)
-    : "f" (x), "f" (mask.d));
+  /* mask to extract the exponent.  */
+  asm ("xxland %x0,%x1,%x2\n"
+       "fcfid  %0,%0"
+       : "=d"(ret)
+       : "d" (x), "d" (0x7ff0000000000000ULL));
   /* ret = (ret >> 52) - 1023.0, since ret is double.  */
-  ret = (ret * two1div52) + two10m1;
-  if (__builtin_expect (ret > -two7m1, 0))
+  ret = (ret * 0x1p-52) - 1023.0;
+  if (ret > 127.0)
     /* Multiplication is used to set logb (+-INF) = INF.  */
     return (x * x);
   /* Since operations are done with double we don't need
@@ -57,4 +50,7 @@ __logbf (float x)
      The test is to avoid logb_downward (0.0) == -0.0.  */
   return ret == -0.0 ? 0.0 : ret;
 }
+# ifndef __logbf
 libm_alias_float (__logb, logb)
+# endif
+#endif
diff --git a/sysdeps/powerpc/power7/fpu/s_logbl.c b/sysdeps/powerpc/fpu/s_logbl.c
similarity index 72%
rename from sysdeps/powerpc/power7/fpu/s_logbl.c
rename to sysdeps/powerpc/fpu/s_logbl.c
index 76c29daeca..543cd4a188 100644
--- a/sysdeps/powerpc/power7/fpu/s_logbl.c
+++ b/sysdeps/powerpc/fpu/s_logbl.c
@@ -1,4 +1,4 @@
-/* logbl(). PowerPC/POWER7 version.
+/* Get exponent of a floating-point value.  PowerPC version.
    Copyright (C) 2012-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,22 +16,17 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_private.h>
-#include <math_ldbl_opt.h>
+/* ISA 2.07 provides fast GPR to FP instruction (mfvsr{d,wz}) which make
+   generic implementation faster.  */
+#if defined(_ARCH_PWR8) || !defined(_ARCH_PWR7)
+# include <./sysdeps/ieee754/ldbl-128ibm/s_logbl.c>
+#else
+# include <math.h>
+# include <math_private.h>
+# include <math_ldbl_opt.h>
 
 /* This implementation avoids FP to INT conversions by using VSX
    bitwise instructions over FP values.  */
-
-static const double two1div52 = 2.220446049250313e-16;	/* 1/2**52  */
-static const double two10m1   = -1023.0;		/* 2**10 -1  */
-
-/* FP mask to extract the exponent.  */
-static const union {
-  unsigned long long mask;
-  double d;
-} mask = { 0x7ff0000000000000ULL };
-
 long double
 __logbl (long double x)
 {
@@ -39,24 +34,23 @@ __logbl (long double x)
   double ret;
   int64_t hx;
 
-  if (__builtin_expect (x == 0.0L, 0))
+  if (__glibc_unlikely (x == 0.0))
     /* Raise FE_DIVBYZERO and return -HUGE_VAL[LF].  */
     return -1.0L / __builtin_fabsl (x);
 
   ldbl_unpack (x, &xh, &xl);
   EXTRACT_WORDS64 (hx, xh);
-  /* ret = x & 0x7ff0000000000000;  */
-  asm (
-    "xxland %x0,%x1,%x2\n"
-    "fcfid  %0,%0"
-    : "=f" (ret)
-    : "f" (xh), "f" (mask.d));
-  /* ret = (ret >> 52) - 1023.0;  */
-  ret = (ret * two1div52) + two10m1;
-  if (__builtin_expect (ret > -two10m1, 0))
+
+  /* Mask to extract the exponent.  */
+  asm ("xxland %x0,%x1,%x2\n"
+       "fcfid  %0,%0"
+       : "=d" (ret)
+       : "d" (xh), "d" (0x7ff0000000000000ULL));
+  ret = (ret * 0x1p-52) - 1023.0;
+  if (ret > 1023.0)
     /* Multiplication is used to set logb (+-INF) = INF.  */
     return (xh * xh);
-  else if (__builtin_expect (ret == two10m1, 0))
+  else if (ret == -1023.0)
     {
       /* POSIX specifies that denormal number is treated as
          though it were normalized.  */
@@ -78,6 +72,7 @@ __logbl (long double x)
   /* Test to avoid logb_downward (0.0) == -0.0.  */
   return ret == -0.0 ? 0.0 : ret;
 }
-#ifndef __logbl
+# ifndef __logbl
 long_double_symbol (libm, __logbl, logbl);
+# endif
 #endif
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb-power7.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb-power7.c
index 812771ac2e..c893ebcf29 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb-power7.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb-power7.c
@@ -16,16 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_ldbl_opt.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-#undef strong_alias
-#define strong_alias(a, b)
-#undef compat_symbol
-#define compat_symbol(lib, name, alias, ver)
-
 #define __logb __logb_power7
-
-#include <sysdeps/powerpc/power7/fpu/s_logb.c>
+#include <sysdeps/powerpc/fpu/s_logb.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbf-power7.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbf-power7.c
index 62c2318421..059c53bce2 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbf-power7.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbf-power7.c
@@ -16,11 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-
-#undef weak_alias
-#define weak_alias(a, b)
-
 #define __logbf __logbf_power7
-
-#include <sysdeps/powerpc/power7/fpu/s_logbf.c>
+#include <sysdeps/powerpc/fpu/s_logbf.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbl-power7.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbl-power7.c
index c4fe590c6c..22a6ffb064 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbl-power7.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbl-power7.c
@@ -17,5 +17,4 @@
    <http://www.gnu.org/licenses/>.  */
 
 #define __logbl __logbl_power7
-
-#include <sysdeps/powerpc/power7/fpu/s_logbl.c>
+#include <sysdeps/powerpc/fpu/s_logbl.c>
diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
index 63de39bbf1..f4e2e88af0 100644
--- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
@@ -32,6 +32,12 @@ libm-sysdep_routines += s_ceil-power5+ \
 			s_llround-power5+ \
 			s_llround-ppc64 \
 			s_llroundf-ppc64 \
+			s_logb-power7 \
+			s_logbf-power7 \
+			s_logbl-power7 \
+			s_logb-ppc64 \
+			s_logbf-ppc64 \
+			s_logbl-ppc64 \
 			$(sysdep_calls:s_%=m_%)
 
 CFLAGS-s_ceil-power5+.c = -mcpu=power5+
@@ -48,6 +54,10 @@ CFLAGS-s_llround-power5+.c += -mcpu=power5+
 
 CFLAGS-s_modf-power5+.c += -mcpu=power5+
 CFLAGS-s_modff-power5+.c += -mcpu=power5+
+CFLAGS-s_logbf-power7.c = -mcpu=power7
+CFLAGS-s_logbl-power7.c = -mcpu=power7
+CFLAGS-s_logb-power7.c = -mcpu=power7
+
 # These files quiet sNaNs in a way that is optimized away without
 # -fsignaling-nans.
 CFLAGS-s_modf-ppc64.c += -fsignaling-nans
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb-power7.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb-power7.c
similarity index 91%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb-power7.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb-power7.c
index 507862b2bf..807bf58eeb 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb-power7.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb-power7.c
@@ -16,4 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb-power7.c>
+#define __logb __logb_power7
+#include <sysdeps/powerpc/fpu/s_logb.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb-ppc64.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb-ppc64.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb-ppc64.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logb.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf-power7.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf-power7.c
similarity index 91%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf-power7.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf-power7.c
index 3535ea78cd..4fee11dd84 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf-power7.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf-power7.c
@@ -16,4 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbf-power7.c>
+#define __logbf __logbf_power7
+#include <sysdeps/powerpc/fpu/s_logbf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf-ppc64.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf-ppc64.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf-ppc64.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbf.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl-power7.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl-power7.c
similarity index 91%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl-power7.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl-power7.c
index 915636176d..c413d6e50d 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl-power7.c
+++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl-power7.c
@@ -16,4 +16,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbl-power7.c>
+#define __logbl __logbl_power7
+#include <sysdeps/powerpc/fpu/s_logbl.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl-ppc64.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl-ppc64.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl-ppc64.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl.c
similarity index 100%
rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbl.c
rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_logbl.c
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
deleted file mode 100644
index d7ad1e2724..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-ifeq ($(subdir),math)
-sysdep_routines += $(sysdep_calls)
-libm-sysdep_routines += s_logb-power7 s_logbf-power7 \
-			s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
-			s_logbl-ppc64 \
-			$(sysdep_calls:s_%=m_%)
-
-CFLAGS-s_logbf-power7.c = -mcpu=power7
-CFLAGS-s_logbl-power7.c = -mcpu=power7
-CFLAGS-s_logb-power7.c = -mcpu=power7
-endif
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c b/sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c
deleted file mode 100644
index 2599c771d9..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_logb.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/powerpc/power7/fpu/s_logb.c>
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_logbf.c b/sysdeps/powerpc/powerpc64/power7/fpu/s_logbf.c
deleted file mode 100644
index 7a5a8032e0..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_logbf.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/powerpc/power7/fpu/s_logbf.c>
diff --git a/sysdeps/powerpc/powerpc64/power7/fpu/s_logbl.c b/sysdeps/powerpc/powerpc64/power7/fpu/s_logbl.c
deleted file mode 100644
index 524ae2c78d..0000000000
--- a/sysdeps/powerpc/powerpc64/power7/fpu/s_logbl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/powerpc/power7/fpu/s_logbl.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 85+ messages in thread

* Re: [PATCH 01/28] powerpc: Use generic fabs{f} implementations
  2019-03-29 13:35 ` [PATCH 01/28] powerpc: Use generic fabs{f} implementations Adhemerval Zanella
@ 2019-04-01 20:04   ` Joseph Myers
  2019-04-03  1:04     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Joseph Myers @ 2019-04-01 20:04 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, 29 Mar 2019, Adhemerval Zanella wrote:

> Since be2e25bbd78f9fdf the generic ieee754 implementation uses
> compiler builtin which generates fabs{f} for all supported targets.

One reason for the existing version might be a microoptimization for code 
size to make the float and double versions aliases, as permitted by the 
ABIs and instruction set in this case.  (This is not an objection to this 
patch.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 02/28] powerpc: fma using builtins
  2019-03-29 13:35 ` [PATCH 02/28] powerpc: fma using builtins Adhemerval Zanella
@ 2019-04-01 20:05   ` Joseph Myers
  2019-04-03  1:06     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Joseph Myers @ 2019-04-01 20:05 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, 29 Mar 2019, Adhemerval Zanella wrote:

> +double __fma (double x, double y, double z)

This is not a correctly formatted function definition (return type should 
be on its own line).

> +float __fmaf (float x, float y, float z)

Likewise.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 24/28] powerpc: hypot refactor and optimization
  2019-03-29 13:35 ` [PATCH 24/28] powerpc: hypot refactor and optimization Adhemerval Zanella
@ 2019-04-01 20:14   ` Joseph Myers
  2019-04-03  1:08     ` Adhemerval Zanella
  2019-06-26 19:59   ` Gabriel F. T. Gomes
  1 sibling, 1 reply; 85+ messages in thread
From: Joseph Myers @ 2019-04-01 20:14 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, 29 Mar 2019, Adhemerval Zanella wrote:

> +  if ((isinf(x) || isinf(y))
> +      && !issignaling (x) && !issignaling (y))
> +    return INFINITY;
> +  if (isnan(x) || isnan(y))
> +    return x + y;

Missign spaces before '('.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 01/28] powerpc: Use generic fabs{f} implementations
  2019-04-01 20:04   ` Joseph Myers
@ 2019-04-03  1:04     ` Adhemerval Zanella
  2019-04-15 20:23       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-04-03  1:04 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 02/04/2019 03:04, Joseph Myers wrote:
> On Fri, 29 Mar 2019, Adhemerval Zanella wrote:
> 
>> Since be2e25bbd78f9fdf the generic ieee754 implementation uses
>> compiler builtin which generates fabs{f} for all supported targets.
> 
> One reason for the existing version might be a microoptimization for code 
> size to make the float and double versions aliases, as permitted by the 
> ABIs and instruction set in this case.  (This is not an objection to this 
> patch.)
> 

Indeed powerpc does such microoptimizations for some implementations, but
if the idea is indeed to push such optimizations couldn't add on generic
implementation though a flag defined in arch-specific headers?

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 02/28] powerpc: fma using builtins
  2019-04-01 20:05   ` Joseph Myers
@ 2019-04-03  1:06     ` Adhemerval Zanella
  2019-04-15 21:44       ` Gabriel F. T. Gomes
  2019-04-17 21:10       ` Joseph Myers
  0 siblings, 2 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-04-03  1:06 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 02/04/2019 03:05, Joseph Myers wrote:
> On Fri, 29 Mar 2019, Adhemerval Zanella wrote:
> 
>> +double __fma (double x, double y, double z)
> 
> This is not a correctly formatted function definition (return type should 
> be on its own line).

Fixed locally.

> 
>> +float __fmaf (float x, float y, float z)
> 
> Likewise.
> 

Ditto.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 24/28] powerpc: hypot refactor and optimization
  2019-04-01 20:14   ` Joseph Myers
@ 2019-04-03  1:08     ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-04-03  1:08 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 02/04/2019 03:14, Joseph Myers wrote:
> On Fri, 29 Mar 2019, Adhemerval Zanella wrote:
> 
>> +  if ((isinf(x) || isinf(y))
>> +      && !issignaling (x) && !issignaling (y))
>> +    return INFINITY;
>> +  if (isnan(x) || isnan(y))
>> +    return x + y;
> 
> Missign spaces before '('.
> 

Fixed locally.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 01/28] powerpc: Use generic fabs{f} implementations
  2019-04-03  1:04     ` Adhemerval Zanella
@ 2019-04-15 20:23       ` Gabriel F. T. Gomes
  2019-04-15 21:32         ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-04-15 20:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Joseph Myers, libc-alpha

On Wed, Apr 03 2019, Adhemerval Zanella wrote:
> 
> 
> On 02/04/2019 03:04, Joseph Myers wrote:
> > On Fri, 29 Mar 2019, Adhemerval Zanella wrote:
> > 
> >> Since be2e25bbd78f9fdf the generic ieee754 implementation uses
> >> compiler builtin which generates fabs{f} for all supported targets.
> > 
> > One reason for the existing version might be a microoptimization for code 
> > size to make the float and double versions aliases, as permitted by the 
> > ABIs and instruction set in this case.  (This is not an objection to this 
> > patch.)
> > 
> 
> Indeed powerpc does such microoptimizations for some implementations, but

The code generated by these functions is as follows (on powerpc64le):

Before the patch:
000000000004dac0 <fabs>:
   4dac0:       0e 00 4c 3c     addis   r2,r12,14
   4dac4:       40 9b 42 38     addi    r2,r2,-25792
   4dac8:       10 0a 20 fc     fabs    f1,f1
   4dacc:       20 00 80 4e     blr

After the patch:
000000000004dac0 <fabs>:
   4dac0:       10 0a 20 fc     fabs    f1,f1
   4dac4:       20 00 80 4e     blr

(this is true when --enable-stack-protector is not in use, or when it is
set to strong, as is the case for the distros I checked (Debian, Fedora
and OpenSuse); when set to all, there would be a lot more differences
before and after the patch, as the assembly implementation wouldn't get
stack protection code, but that's not a problem, imo).

(also, the absence of the TOC-setup code is fine, as the function does
not need anything from the TOC).

> if the idea is indeed to push such optimizations couldn't add on generic
> implementation though a flag defined in arch-specific headers?

Given the size of these functions, I believe that this is not worth the
effort, and I believe this patch is OK as is.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 01/28] powerpc: Use generic fabs{f} implementations
  2019-04-15 20:23       ` Gabriel F. T. Gomes
@ 2019-04-15 21:32         ` Tulio Magno Quites Machado Filho
  2019-04-17 17:08           ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2019-04-15 21:32 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, Adhemerval Zanella; +Cc: Joseph Myers, libc-alpha

"Gabriel F. T. Gomes" <gabriel@inconstante.eti.br> writes:

> The code generated by these functions is as follows (on powerpc64le):
>
> Before the patch:
> 000000000004dac0 <fabs>:
>    4dac0:       0e 00 4c 3c     addis   r2,r12,14
>    4dac4:       40 9b 42 38     addi    r2,r2,-25792
>    4dac8:       10 0a 20 fc     fabs    f1,f1
>    4dacc:       20 00 80 4e     blr
>
> After the patch:
> 000000000004dac0 <fabs>:
>    4dac0:       10 0a 20 fc     fabs    f1,f1
>    4dac4:       20 00 80 4e     blr

This is showing that __fabs could have been using ENTRY_TOCLESS instead of
ENTRY. ;-)

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 02/28] powerpc: fma using builtins
  2019-04-03  1:06     ` Adhemerval Zanella
@ 2019-04-15 21:44       ` Gabriel F. T. Gomes
  2019-04-17 21:10       ` Joseph Myers
  1 sibling, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-04-15 21:44 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Joseph Myers, libc-alpha

On Wed, Apr 03 2019, Adhemerval Zanella wrote:
> 
> On 02/04/2019 03:05, Joseph Myers wrote:
> > On Fri, 29 Mar 2019, Adhemerval Zanella wrote:
> > 
> >> +double __fma (double x, double y, double z)
> > 
> > This is not a correctly formatted function definition (return type should 
> > be on its own line).
> 
> Fixed locally.
> 
> > 
> >> +float __fmaf (float x, float y, float z)
> > 
> > Likewise.
> > 
> 
> Ditto.

Looks good to me.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 01/28] powerpc: Use generic fabs{f} implementations
  2019-04-15 21:32         ` Tulio Magno Quites Machado Filho
@ 2019-04-17 17:08           ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-04-17 17:08 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho, Gabriel F. T. Gomes
  Cc: Joseph Myers, libc-alpha



On 15/04/2019 18:32, Tulio Magno Quites Machado Filho wrote:
> "Gabriel F. T. Gomes" <gabriel@inconstante.eti.br> writes:
> 
>> The code generated by these functions is as follows (on powerpc64le):
>>
>> Before the patch:
>> 000000000004dac0 <fabs>:
>>    4dac0:       0e 00 4c 3c     addis   r2,r12,14
>>    4dac4:       40 9b 42 38     addi    r2,r2,-25792
>>    4dac8:       10 0a 20 fc     fabs    f1,f1
>>    4dacc:       20 00 80 4e     blr
>>
>> After the patch:
>> 000000000004dac0 <fabs>:
>>    4dac0:       10 0a 20 fc     fabs    f1,f1
>>    4dac4:       20 00 80 4e     blr
> 
> This is showing that __fabs could have been using ENTRY_TOCLESS instead of
> ENTRY. ;-)
> 

And another point try use C implementation where possible (since it
abstracts that kind of possible ABI issues) ;)

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 02/28] powerpc: fma using builtins
  2019-04-03  1:06     ` Adhemerval Zanella
  2019-04-15 21:44       ` Gabriel F. T. Gomes
@ 2019-04-17 21:10       ` Joseph Myers
  2019-04-17 21:28         ` Adhemerval Zanella
  1 sibling, 1 reply; 85+ messages in thread
From: Joseph Myers @ 2019-04-17 21:10 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Wed, 3 Apr 2019, Adhemerval Zanella wrote:

> On 02/04/2019 03:05, Joseph Myers wrote:
> > On Fri, 29 Mar 2019, Adhemerval Zanella wrote:
> > 
> >> +double __fma (double x, double y, double z)
> > 
> > This is not a correctly formatted function definition (return type should 
> > be on its own line).
> 
> Fixed locally.
> 
> > 
> >> +float __fmaf (float x, float y, float z)
> > 
> > Likewise.
> > 
> 
> Ditto.

The committed changes appear to be the wrong version, as they still have 
the incorrect formatting.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 02/28] powerpc: fma using builtins
  2019-04-17 21:10       ` Joseph Myers
@ 2019-04-17 21:28         ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-04-17 21:28 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 17/04/2019 18:10, Joseph Myers wrote:
> On Wed, 3 Apr 2019, Adhemerval Zanella wrote:
> 
>> On 02/04/2019 03:05, Joseph Myers wrote:
>>> On Fri, 29 Mar 2019, Adhemerval Zanella wrote:
>>>
>>>> +double __fma (double x, double y, double z)
>>>
>>> This is not a correctly formatted function definition (return type should 
>>> be on its own line).
>>
>> Fixed locally.
>>
>>>
>>>> +float __fmaf (float x, float y, float z)
>>>
>>> Likewise.
>>>
>>
>> Ditto.
> 
> The committed changes appear to be the wrong version, as they still have 
> the incorrect formatting.
> 

Sorry about that, I will fix.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 03/28] powerpc: Remove power4 mpa optimization
  2019-03-29 13:35 ` [PATCH 03/28] powerpc: Remove power4 mpa optimization Adhemerval Zanella
@ 2019-04-24 21:51   ` Gabriel F. T. Gomes
  2019-04-25 12:19     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-04-24 21:51 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha


On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> This patch removes the POWER4 optimized mpa optimization used for power4+
> build.  For newer chips, GCC generates *worse* code than generic
> implementation as benchmaks result below.

I don't think I have access to POWER4 hardware, but when running
power4-targeted builds on newer processors, I saw no performance
degradation even in that scenario.

> One possibilty would to add
> IFUNC variants for the mpa routines (as x86_64), but it will add complexity
> only for older chips (and one would need to check if power5, power5+, and
> power6 do benefict from this optimization), and only for specific
> implementation (since most used ones such as sin, cos, exp, pow already
> avoid calling the slow multiprecision path).

I don't think it's worth the effort.

> Checked on powerpc-linux-gnu (built without --with-cpu, with
> --with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
> powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
> and --disable-multi-arch).

Thanks for the thorough checking.

> 	* sysdeps/powerpc/power4/fpu/Makefile: Remove file.
> 	* sysdeps/powerpc/power4/fpu/mpa-arch.h: Likewise.
> 	* sysdeps/powerpc/power4/fpu/mpa.c: Likewise.

Looks good to me.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 04/28] powerpc: ceil/ceilf refactor
  2019-03-29 13:35 ` [PATCH 04/28] powerpc: ceil/ceilf refactor Adhemerval Zanella
@ 2019-04-25  1:56   ` Gabriel F. T. Gomes
  2019-04-25 21:58     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-04-25  1:56 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> The IFUNC organization for powerpc64 is also change to be enabled only
> for powerpc64 and not for powerpc64le.

OK.

> 	* sysdeps/powerpc/fpu/fenv_libc.h (__fesetround_inline_nocheck): New
> 	macro.

I really wish we can get rid of the burden of writing changelogs, but
for now shouldn't this be function, instead of macro?

> +/* Same as __fesetround_inline, however without runtime check to use DFP
> +   mtfsfi syntax or if round is valid.  */

What would be a runtime check to use DFP syntax? Are you referring to
the optional third parameter (W) to mtfsfi?  I don't see such mechanism
in __fesetround_inline, so I'm not sure I understand this
comment/comparison.

> +static inline void
> +__fesetround_inline_nocheck (const int round)
> +{
> +  asm volatile ("mtfsfi 7,%0" : : "i" (round));
> +}
> +

The implementation looks OK.

> +enum round_mode
> +{
> +  CEIL,
> +  FLOOR,
> +  ROUND,
> +  TRUNC,
> +  NEARBYINT,
> +};

OK.  To be used in following patches.

> +static inline void
> +set_fenv_mode (enum round_mode mode)
> +{
> +  int rmode;
> +  switch (mode)
> +  {
> +  case CEIL:  rmode = FE_UPWARD; break;
> +  default:    rmode = FE_TONEAREST; break;
> +  }
> +  __fesetround_inline_nocheck (rmode);
> +}

OK.

> +static inline float
> +round_to_integer_float (enum round_mode mode, float x)
> +{
> +  /* Ensure sNaN input is converted to qNaN.  */
> +  if (__glibc_unlikely (isnan (x)))
> +    return x + x;
> +
> +  if (fabs (x) > 0x1p+23)
> +    return x;
> +
> +  float r = x;
> +
> +  /* Save current FPU rounding mode and inexact state.  */
> +  fenv_t fe = fegetenv_register ();
> +  set_fenv_mode (mode);
> +  if (x > 0.0)
> +    {
> +      r += 0x1p+23;
> +      r -= 0x1p+23;
> +      r = fabs (r);
> +    }
> +  else if (x < 0.0)
> +    {
> +      r -= 0x1p+23;
> +      r += 0x1p+23;
> +      r = -fabs (r);
> +    }
> +  __builtin_mtfsf (0xff, fe);
> +
> +  return r;
> +}

Ok.

> +static inline double
> +round_to_integer_double (enum round_mode mode, double x)
> +{
> +  /* Ensure sNaN input is converted to qNaN.  */
> +  if (__glibc_unlikely (isnan (x)))
> +    return x + x;
> +
> +  if (fabs (x) > 0x1p+52)
> +    return x;
> +
> +  double r = x;
> +
> +  /* Save current FPU rounding mode and inexact state.  */
> +  fenv_t fe = fegetenv_register ();
> +  set_fenv_mode (mode);
> +  if (x > 0.0)
> +    {
> +      r += 0x1p+52;
> +      r -= 0x1p+52;
> +      r = fabs (r);
> +    }
> +  else if (x < 0.0)
> +    {
> +      r -= 0x1p+52;
> +      r += 0x1p+52;
> +      r = -fabs (r);
> +    }
> +  __builtin_mtfsf (0xff, fe);
> +
> +  return r;
> +}

OK.

> +double
> +__ceil (double x)
> +{
> +#ifdef _ARCH_PWR5X
> +  return __builtin_ceil (x);
> +#else
> +  return round_to_integer_double (CEIL, x);
> +#endif

The arch check looks correct.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 03/28] powerpc: Remove power4 mpa optimization
  2019-04-24 21:51   ` Gabriel F. T. Gomes
@ 2019-04-25 12:19     ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-04-25 12:19 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 24/04/2019 18:51, Gabriel F. T. Gomes wrote:
> 
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>> This patch removes the POWER4 optimized mpa optimization used for power4+
>> build.  For newer chips, GCC generates *worse* code than generic
>> implementation as benchmaks result below.
> 
> I don't think I have access to POWER4 hardware, but when running
> power4-targeted builds on newer processors, I saw no performance
> degradation even in that scenario.

My guess is the optimization was trying to overcome some compiler
missed optimization (POWER4 was released at same time as GCC 3.2.3
and mostly likely distributions were using even older releases to
build system libc).

> 
>> One possibilty would to add
>> IFUNC variants for the mpa routines (as x86_64), but it will add complexity
>> only for older chips (and one would need to check if power5, power5+, and
>> power6 do benefict from this optimization), and only for specific
>> implementation (since most used ones such as sin, cos, exp, pow already
>> avoid calling the slow multiprecision path).
> 
> I don't think it's worth the effort.

Agreed.

> 
>> Checked on powerpc-linux-gnu (built without --with-cpu, with
>> --with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
>> powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
>> and --disable-multi-arch).
> 
> Thanks for the thorough checking.
> 
>> 	* sysdeps/powerpc/power4/fpu/Makefile: Remove file.
>> 	* sysdeps/powerpc/power4/fpu/mpa-arch.h: Likewise.
>> 	* sysdeps/powerpc/power4/fpu/mpa.c: Likewise.
> 
> Looks good to me.
> 
> Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
> 

Thanks.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 04/28] powerpc: ceil/ceilf refactor
  2019-04-25  1:56   ` Gabriel F. T. Gomes
@ 2019-04-25 21:58     ` Adhemerval Zanella
  2019-05-02 18:41       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-04-25 21:58 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 24/04/2019 22:56, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>>
>> The IFUNC organization for powerpc64 is also change to be enabled only
>> for powerpc64 and not for powerpc64le.
> 
> OK.
> 
>> 	* sysdeps/powerpc/fpu/fenv_libc.h (__fesetround_inline_nocheck): New
>> 	macro.
> 
> I really wish we can get rid of the burden of writing changelogs, but
> for now shouldn't this be function, instead of macro?
> 
>> +/* Same as __fesetround_inline, however without runtime check to use DFP
>> +   mtfsfi syntax or if round is valid.  */
> 
> What would be a runtime check to use DFP syntax? Are you referring to
> the optional third parameter (W) to mtfsfi?  I don't see such mechanism
> in __fesetround_inline, so I'm not sure I understand this
> comment/comparison.

The comment is not clear indeed, to use mtfsfi correctly one should
check hwcap for PPC_FEATURE_HAS_DFP as fesetenv_register do.  I changed
comment to:

/* Same as __fesetround_inline, however without runtime check to use DFP
   mtfsfi syntax (as relax_fenv_state) or if round value is valid.  */

> 
>> +static inline void
>> +__fesetround_inline_nocheck (const int round)
>> +{
>> +  asm volatile ("mtfsfi 7,%0" : : "i" (round));
>> +}
>> +
> 
> The implementation looks OK.
> 
>> +enum round_mode
>> +{
>> +  CEIL,
>> +  FLOOR,
>> +  ROUND,
>> +  TRUNC,
>> +  NEARBYINT,
>> +};
> 
> OK.  To be used in following patches.

In fact I think it would be better to add each round_mode on each
patch it implements. I have changed it locally.

> 
>> +static inline void
>> +set_fenv_mode (enum round_mode mode)
>> +{
>> +  int rmode;
>> +  switch (mode)
>> +  {
>> +  case CEIL:  rmode = FE_UPWARD; break;
>> +  default:    rmode = FE_TONEAREST; break;
>> +  }
>> +  __fesetround_inline_nocheck (rmode);
>> +}
> 
> OK.
> 
>> +static inline float
>> +round_to_integer_float (enum round_mode mode, float x)
>> +{
>> +  /* Ensure sNaN input is converted to qNaN.  */
>> +  if (__glibc_unlikely (isnan (x)))
>> +    return x + x;
>> +
>> +  if (fabs (x) > 0x1p+23)
>> +    return x;
>> +
>> +  float r = x;
>> +
>> +  /* Save current FPU rounding mode and inexact state.  */
>> +  fenv_t fe = fegetenv_register ();
>> +  set_fenv_mode (mode);
>> +  if (x > 0.0)
>> +    {
>> +      r += 0x1p+23;
>> +      r -= 0x1p+23;
>> +      r = fabs (r);
>> +    }
>> +  else if (x < 0.0)
>> +    {
>> +      r -= 0x1p+23;
>> +      r += 0x1p+23;
>> +      r = -fabs (r);
>> +    }
>> +  __builtin_mtfsf (0xff, fe);
>> +
>> +  return r;
>> +}
> 
> Ok.
> 
>> +static inline double
>> +round_to_integer_double (enum round_mode mode, double x)
>> +{
>> +  /* Ensure sNaN input is converted to qNaN.  */
>> +  if (__glibc_unlikely (isnan (x)))
>> +    return x + x;
>> +
>> +  if (fabs (x) > 0x1p+52)
>> +    return x;
>> +
>> +  double r = x;
>> +
>> +  /* Save current FPU rounding mode and inexact state.  */
>> +  fenv_t fe = fegetenv_register ();
>> +  set_fenv_mode (mode);
>> +  if (x > 0.0)
>> +    {
>> +      r += 0x1p+52;
>> +      r -= 0x1p+52;
>> +      r = fabs (r);
>> +    }
>> +  else if (x < 0.0)
>> +    {
>> +      r -= 0x1p+52;
>> +      r += 0x1p+52;
>> +      r = -fabs (r);
>> +    }
>> +  __builtin_mtfsf (0xff, fe);
>> +
>> +  return r;
>> +}
> 
> OK.
> 
>> +double
>> +__ceil (double x)
>> +{
>> +#ifdef _ARCH_PWR5X
>> +  return __builtin_ceil (x);
>> +#else
>> +  return round_to_integer_double (CEIL, x);
>> +#endif
> 
> The arch check looks correct.
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 04/28] powerpc: ceil/ceilf refactor
  2019-04-25 21:58     ` Adhemerval Zanella
@ 2019-05-02 18:41       ` Gabriel F. T. Gomes
  2019-05-04 21:46         ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-02 18:41 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Thu, Apr 25 2019, Adhemerval Zanella wrote:
> On 24/04/2019 22:56, Gabriel F. T. Gomes wrote:
> 
> > What would be a runtime check to use DFP syntax? Are you referring to
> > the optional third parameter (W) to mtfsfi?  I don't see such mechanism
> > in __fesetround_inline, so I'm not sure I understand this
> > comment/comparison.
> 
> The comment is not clear indeed, to use mtfsfi correctly one should
> check hwcap for PPC_FEATURE_HAS_DFP as fesetenv_register do.  I changed
> comment to:
> 
> /* Same as __fesetround_inline, however without runtime check to use DFP
>    mtfsfi syntax (as relax_fenv_state) or if round value is valid.  */

Aha, now I get it, thanks.  With this change, the patch looks good to me.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

> >> +enum round_mode
> >> +{
> >> +  CEIL,
> >> +  FLOOR,
> >> +  ROUND,
> >> +  TRUNC,
> >> +  NEARBYINT,
> >> +};
> > 
> > OK.  To be used in following patches.
> 
> In fact I think it would be better to add each round_mode on each
> patch it implements. I have changed it locally.

OK.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 05/28] powerpc: floor/floorf refactor
  2019-03-29 13:35 ` [PATCH 05/28] powerpc: floor/floorf refactor Adhemerval Zanella
@ 2019-05-03 21:44   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-03 21:44 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> 	* sysdeps/powerpc/fpu/round_to_integer.h (set_rounding_mode):
> 	Add FLOOR option.

Since you removed the definition of FLOOR from round_mode (enum) in the
previous patch, make sure you updated this ChangeLog entry with
something similar to:

	(round_mode): Add definition for FLOOR.

> diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
> index 417aae6242..77d9fc1f86 100644
> --- a/sysdeps/powerpc/fpu/round_to_integer.h
> +++ b/sysdeps/powerpc/fpu/round_to_integer.h
> @@ -37,6 +37,7 @@ set_fenv_mode (enum round_mode mode)
>    switch (mode)
>    {
>    case CEIL:  rmode = FE_UPWARD; break;
> +  case FLOOR: rmode = FE_DOWNWARD; break;
>    default:    rmode = FE_TONEAREST; break;
>    }
>    __fesetround_inline_nocheck (rmode);

Likewise, in this file, make sure you added the definition for FLOOR.

The patch looks good to me, with these changes.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

> +double
> +__floor (double x)
> +{
> +#ifdef _ARCH_PWR5X
> +  return __builtin_floor (x);
> +#else
> +  return round_to_integer_double (FLOOR, x);
> +#endif
> +}

OK.  The arch check looks correct.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 06/28] powerpc: round/roundf refactor
  2019-03-29 13:35 ` [PATCH 06/28] powerpc: round/roundf refactor Adhemerval Zanella
@ 2019-05-04  1:10   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-04  1:10 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> 	* sysdeps/powerpc/fpu/round_to_integer.h (set_rounding_mode): Add
> 	ROUND handling.
> 	(round_to_integer_float): Likewise.

Similar to what I mentioned for the floor patch, just make sure you
mention the addition of the ROUND definition.

> diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
> index 77d9fc1f86..3fa2b77b6d 100644
> --- a/sysdeps/powerpc/fpu/round_to_integer.h
> +++ b/sysdeps/powerpc/fpu/round_to_integer.h
> @@ -38,6 +38,7 @@ set_fenv_mode (enum round_mode mode)
>    {
>    case CEIL:  rmode = FE_UPWARD; break;
>    case FLOOR: rmode = FE_DOWNWARD; break;
> +  case ROUND: rmode = FE_TOWARDZERO; break;
>    default:    rmode = FE_TONEAREST; break;
>    }

Likewise, check that the FLOOR definition is added to round_mode.

This patch looks good to me with these changes.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>


> @@ -60,12 +61,24 @@ round_to_integer_float (enum round_mode mode, float x)
>    set_fenv_mode (mode);
>    if (x > 0.0)
>      {
> +      /* IEEE 1003.1 round function.  IEEE specifies "round to the nearest
> +	 integer value, rounding halfway cases away from zero, regardless of
> +	 the current rounding mode."  However PowerPC Architecture defines
> +	 "Round to Nearest" as "Choose the best approximation. In case of a
> +	 tie, choose the one that is even (least significant bit o).".
> +	 So we can't use the PowerPC "Round to Nearest" mode. Instead we set
> +	 "Round toward Zero" mode and round by adding +-0.5 before rounding
> +	 to the integer value.  */
> +      if (mode == ROUND)
> +	r += 0.5f;
>        r += 0x1p+23;
>        r -= 0x1p+23;
>        r = fabs (r);
>      }
>    else if (x < 0.0)
>      {
> +      if (mode == ROUND)
> +	r -= 0.5f;
>        r -= 0x1p+23;
>        r += 0x1p+23;
>        r = -fabs (r);

OK.  Restored from the .S files.

> @@ -92,12 +105,16 @@ round_to_integer_double (enum round_mode mode, double x)
>    set_fenv_mode (mode);
>    if (x > 0.0)
>      {
> +      if (mode == ROUND)
> +	r += 0.5;
>        r += 0x1p+52;
>        r -= 0x1p+52;
>        r = fabs (r);
>      }
>    else if (x < 0.0)
>      {
> +      if (mode == ROUND)
> +	r -= 0.5;
>        r -= 0x1p+52;
>        r += 0x1p+52;
>        r = -fabs (r);

OK.  Likewise.

> +double
> +__round (double x)
> +{
> +#ifdef _ARCH_PWR5X
> +  return __builtin_round (x);
> +#else
> +  return round_to_integer_double (ROUND, x);
> +#endif
> +}

OK.  Arch check looks correct.

> -.LC1:	/* 0.5 */
> -	.long 0x3f000000
> -
> -/* double [fp1] round (double x [fp1])
> -   IEEE 1003.1 round function.  IEEE specifies "round to the nearest
> -   integer value, rounding halfway cases away from zero, regardless of
> -   the current rounding mode."  However PowerPC Architecture defines
> -   "Round to Nearest" as "Choose the best approximation. In case of a
> -   tie, choose the one that is even (least significant bit o).".
> -   So we can't use the PowerPC "Round to Nearest" mode. Instead we set
> -   "Round toward Zero" mode and round by adding +-0.5 before rounding
> -   to the integer value.  */
>
> [...]
>
> -#ifdef SHARED
> -	lfs	fp10,.LC1-.LC0(r9)
> -#else
> -	lis	r9,.LC1@ha
> -	lfs	fp10,.LC1@l(r9)
> -#endif
> -	ble-	cr6,.L4
> -	fadd	fp1,fp1,fp10	/* x+= 0.5;  */

OK.  Moved to round_to_integer_float and round_to_integer_double.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 04/28] powerpc: ceil/ceilf refactor
  2019-05-02 18:41       ` Gabriel F. T. Gomes
@ 2019-05-04 21:46         ` Gabriel F. T. Gomes
  2019-05-06 12:22           ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-04 21:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

Hi, Adhemerval,

During the review of the patch for trunc{,f}, I noticed something that
affects this patch, as well as the patches for floor and round.

Before the changes, the POWER5+ version of the float functions perform a
round to float (via a frsp instruction), because this is explicit in the
assembly code, for instance:

> -ENTRY_TOCLESS (__ceilf, 4)
> -	CALL_MCOUNT 0
> -	frip	fp1, fp1	/* The rounding instructions are double.  */
> -	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
> -	blr
> -	END (__ceilf)

When this assembly function gets replaced with the builtin, the
generated code does not perform the round to float and will not set
ooverflow (as mentioned in the comment above).

  $ objdump -d math/libm.so.6 | grep -E "<ceilf>:" -A 3
  0000000000060690 <ceilf>:
     60690:       90 0b 20 fc     frip    f1,f1
     60694:       20 00 80 4e     blr
          ...

I still don't know it that is actually a problem.  Do you know?  I'm
sorry that I didn't notice this before.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 04/28] powerpc: ceil/ceilf refactor
  2019-05-04 21:46         ` Gabriel F. T. Gomes
@ 2019-05-06 12:22           ` Adhemerval Zanella
  2019-05-09 19:56             ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-05-06 12:22 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 04/05/2019 18:46, Gabriel F. T. Gomes wrote:
> Hi, Adhemerval,
> 
> During the review of the patch for trunc{,f}, I noticed something that
> affects this patch, as well as the patches for floor and round.
> 
> Before the changes, the POWER5+ version of the float functions perform a
> round to float (via a frsp instruction), because this is explicit in the
> assembly code, for instance:
> 
>> -ENTRY_TOCLESS (__ceilf, 4)
>> -	CALL_MCOUNT 0
>> -	frip	fp1, fp1	/* The rounding instructions are double.  */
>> -	frsp	fp1, fp1	/* But we need to set ooverflow for float.  */
>> -	blr
>> -	END (__ceilf)
> 
> When this assembly function gets replaced with the builtin, the
> generated code does not perform the round to float and will not set
> ooverflow (as mentioned in the comment above).
> 
>   $ objdump -d math/libm.so.6 | grep -E "<ceilf>:" -A 3
>   0000000000060690 <ceilf>:
>      60690:       90 0b 20 fc     frip    f1,f1
>      60694:       20 00 80 4e     blr
>           ...
> 
> I still don't know it that is actually a problem.  Do you know?  I'm
> sorry that I didn't notice this before.
> 

My understanding is the frsp was added to align the implementation to 
POSIX 2001 [1] description which contains a possible range error.
However, as described by man-pages [2], this error for IEEE 754
formats can not happen in practice (the maximum value of exponent for
float, 2^127, is larger than maximum value by significand, 2^23).

This was in fact corrected by both C99 and POSIX 2008 [3] by removing 
the possible return error. So, as gcc builtin implements, the frsp
is superfluous. 

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/ceil.html
[2] http://man7.org/linux/man-pages/man3/ceil.3.html
[3] https://pubs.opengroup.org/onlinepubs/9699919799/functions/ceil.html

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 04/28] powerpc: ceil/ceilf refactor
  2019-05-06 12:22           ` Adhemerval Zanella
@ 2019-05-09 19:56             ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-09 19:56 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mon, May 06 2019, Adhemerval Zanella wrote:
> 
> My understanding is the frsp was added to align the implementation to 
> POSIX 2001 [1] description which contains a possible range error.
> However, as described by man-pages [2], this error for IEEE 754
> formats can not happen in practice (the maximum value of exponent for
> float, 2^127, is larger than maximum value by significand, 2^23).

I see, and the check (if (fabs (x) > 0x1p+23) return x), at the
beginning of the function, guarantees that an overflow is never caused
by the following addition and subtraction (or vice versa) of 2^23.
Thanks for the clarification.

> This was in fact corrected by both C99 and POSIX 2008 [3] by removing 
> the possible return error. So, as gcc builtin implements, the frsp
> is superfluous. 
> 
> [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/ceil.html
> [2] http://man7.org/linux/man-pages/man3/ceil.3.html
> [3] https://pubs.opengroup.org/onlinepubs/9699919799/functions/ceil.html

Thanks for the references, too.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 07/28] powerpc: trunc/truncf refactor
  2019-03-29 13:35 ` [PATCH 07/28] powerpc: trunc/truncf refactor Adhemerval Zanella
@ 2019-05-09 20:06   ` Gabriel F. T. Gomes
  2019-05-09 20:54     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-09 20:06 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> 	* sysdeps/powerpc/fpu/trunc_to_integer.h (set_truncing_mode): Add
> 	 TRUNC handling.

Similar to floor and round, remember to add a note here about the
definition of TRUNC.

> --- a/sysdeps/powerpc/fpu/round_to_integer.h
> +++ b/sysdeps/powerpc/fpu/round_to_integer.h
> @@ -38,6 +38,7 @@ set_fenv_mode (enum round_mode mode)
>    {
>    case CEIL:  rmode = FE_UPWARD; break;
>    case FLOOR: rmode = FE_DOWNWARD; break;
> +  case TRUNC:
>    case ROUND: rmode = FE_TOWARDZERO; break;
>    default:    rmode = FE_TONEAREST; break;
>    }

Likewise, remember to add the definition of TRUNC.

The patch looks good to me with these changes.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

> +double
> +__trunc (double x)
> +{
> +#ifdef _ARCH_PWR5X
> +  return __builtin_trunc (x);
> +#else
> +  return round_to_integer_double (TRUNC, x);
> +#endif
> +}

OK.  Arch check looks correct.

> -/* double [fp1] trunc (double x [fp1])
> -   IEEE 1003.1 trunc function.  IEEE specifies "trunc to the integer
> -   value, in floating format, nearest to but no larger in magnitude
> -   then the argument."
> -   We set "round toward Zero" mode and trunc by adding +-2**52 then
> -   subtracting +-2**52.  */

This comment got lost.  Would you deem it appropriate to reinstate it
somewhere in round_to_integer_double (you would need to make it generic
so that it fits the four rounding directions (so far), as well as
nearbyint from the subsequent patch... perhaps something along the lines
of the paragraph below)?

  IEEE 1003.1 nearest integer functions.  IEEE specifies several
  functions that approximate a floating-point to a nearby integer value.
  For each of them we set the appropriate rounding mode, then add and
  subtract +-2**52.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 07/28] powerpc: trunc/truncf refactor
  2019-05-09 20:06   ` Gabriel F. T. Gomes
@ 2019-05-09 20:54     ` Adhemerval Zanella
  2019-05-09 21:36       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-05-09 20:54 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 09/05/2019 17:06, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>>
>> 	* sysdeps/powerpc/fpu/trunc_to_integer.h (set_truncing_mode): Add
>> 	 TRUNC handling.
> 
> Similar to floor and round, remember to add a note here about the
> definition of TRUNC.
> 
>> --- a/sysdeps/powerpc/fpu/round_to_integer.h
>> +++ b/sysdeps/powerpc/fpu/round_to_integer.h
>> @@ -38,6 +38,7 @@ set_fenv_mode (enum round_mode mode)
>>    {
>>    case CEIL:  rmode = FE_UPWARD; break;
>>    case FLOOR: rmode = FE_DOWNWARD; break;
>> +  case TRUNC:
>>    case ROUND: rmode = FE_TOWARDZERO; break;
>>    default:    rmode = FE_TONEAREST; break;
>>    }
> 
> Likewise, remember to add the definition of TRUNC.
> 
> The patch looks good to me with these changes.
> 
> Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
> 
>> +double
>> +__trunc (double x)
>> +{
>> +#ifdef _ARCH_PWR5X
>> +  return __builtin_trunc (x);
>> +#else
>> +  return round_to_integer_double (TRUNC, x);
>> +#endif
>> +}
> 
> OK.  Arch check looks correct.
> 
>> -/* double [fp1] trunc (double x [fp1])
>> -   IEEE 1003.1 trunc function.  IEEE specifies "trunc to the integer
>> -   value, in floating format, nearest to but no larger in magnitude
>> -   then the argument."
>> -   We set "round toward Zero" mode and trunc by adding +-2**52 then
>> -   subtracting +-2**52.  */
> 
> This comment got lost.  Would you deem it appropriate to reinstate it
> somewhere in round_to_integer_double (you would need to make it generic
> so that it fits the four rounding directions (so far), as well as
> nearbyint from the subsequent patch... perhaps something along the lines
> of the paragraph below)?
> 
>   IEEE 1003.1 nearest integer functions.  IEEE specifies several
>   functions that approximate a floating-point to a nearby integer value.
>   For each of them we set the appropriate rounding mode, then add and
>   subtract +-2**52.
> 

My view is such direct comments is useful on assembly implementation
where is not really obvious what the instruction sequence is doing.
I usually see that the C counterpart should be straightforward to infer
this. I can reinstate the comment though if you think it is really
valuable.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 07/28] powerpc: trunc/truncf refactor
  2019-05-09 20:54     ` Adhemerval Zanella
@ 2019-05-09 21:36       ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-09 21:36 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Thu, May 09 2019, Adhemerval Zanella wrote:
> 
> On 09/05/2019 17:06, Gabriel F. T. Gomes wrote:
> >
> > This comment got lost.  Would you deem it appropriate to reinstate it
> > somewhere in round_to_integer_double (you would need to make it generic
> > so that it fits the four rounding directions (so far), as well as
> > nearbyint from the subsequent patch... perhaps something along the lines
> > of the paragraph below)?
> > 
> >   IEEE 1003.1 nearest integer functions.  IEEE specifies several
> >   functions that approximate a floating-point to a nearby integer value.
> >   For each of them we set the appropriate rounding mode, then add and
> >   subtract +-2**52.
> > 
> 
> My view is such direct comments is useful on assembly implementation
> where is not really obvious what the instruction sequence is doing.
> I usually see that the C counterpart should be straightforward to infer
> this. I can reinstate the comment though if you think it is really
> valuable.

I guess you are right. The patch is good without the comment.

Thanks.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 08/28] powerpc: generic nearbyint/nearbyintf
  2019-03-29 13:35 ` [PATCH 08/28] powerpc: generic nearbyint/nearbyintf Adhemerval Zanella
@ 2019-05-27 20:42   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-27 20:42 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>
> 	* sysdeps/powerpc/fpu/round_to_integer.h (set_fenv_mode): Add
> 	NEARBYINT handling.
> 	* sysdeps/powerpc/fpu/s_nearbyint.c: New file.
> 	* sysdeps/powerpc/fpu/s_nearbyintf.c: Likewise.
> 	* sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S: Remove file.
> 	* sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Likewise.

OK.

> +  case NEARBYINT:
> +    /*  Disable FE_INEXACT exception  */
> +    reset_fpscr_bit (FPSCR_XE);
> +    break;

OK.  Do not change round direction and disable the inexact exception.

> -	mffs	fp11
> -	mtfsb0	4*cr7+lt	/* Disable FE_INEXACT exception */

OK. Behaviour copied to the C implementation.

Looks good to me, thanks.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 09/28] powerpc: consolidate rint
  2019-03-29 13:35 ` [PATCH 09/28] powerpc: consolidate rint Adhemerval Zanella
@ 2019-05-30 14:36   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-30 14:36 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> 	* sysdeps/powerpc/fpu/round_to_integer.h (set_fenv_mode,
> 	round_to_integer_float): Add RINT handling.

I think you should also add 'round_mode' to the list of entities that
got RINT handling added.

> 	(reset_fenv_mode): New symbol.
> 	* sysdeps/powerpc/fpu/s_rint.c (__rint): Use generic implementation.
> 	* sysdeps/powerpc/fpu/s_rintf.c (__rintf): Likewise.

OK.

> 	* sysdeps/powerpc/powerpc32/fpu/s_rint.S: Likewise.
> 	* sysdeps/powerpc/powerpc32/fpu/s_rintf.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/s_rint.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/s_rintf.S: Likewise.

Although 'Likewise' is semantically correct, I think these should be
listed as 'Remove file'.

Looks good to me.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

>  set_fenv_mode (enum round_mode mode)
>  {
> +  fenv_t fe = 0;
> +  if (mode != RINT)
> +    /* Save current FPU rounding mode and inexact state.  */
> +    fe = fegetenv_register ();
> +
>    switch (mode)
>    {
>    case CEIL:
> @@ -49,6 +55,22 @@ set_fenv_mode (enum round_mode mode)
>      /*  Disable FE_INEXACT exception  */
>      reset_fpscr_bit (FPSCR_XE);
>      break;
> +  case RINT:
> +    break;
> +  }
> +  return fe;

OK.  rint is like nearbyint but might raise INEXACT.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 10/28] powerpc: copysign cleanup
  2019-03-29 13:35 ` [PATCH 10/28] powerpc: copysign cleanup Adhemerval Zanella
@ 2019-05-31 14:14   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-05-31 14:14 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

Looks good with the minor fixes below.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> GCC always expand copysign{f} for all possible cpus, so calling the libm
> is only done if user explicitly states to disable the builtin (which is
> usually done not for performance reason).  So to provide ifunc variant
> for copysign only adds complexity for powerpc and powerpc64 and it not
> required for powerpc64le.

OK.

> 	* sysdeps/powerpc/fpu/s_copysign.c: New file.
> 	* sysdeps/powerpc/fpu/s_copysignf.c: Likewise.
> 	* sysdeps/powerpc/powerpc32/fpu/s_copysign.S: Remove file.
> 	* sysdeps/powerpc/powerpc32/fpu/s_copysignf.S: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
> 	(sysdep_routines, libm-sysdep_routines): Remove s_copysign-power6 and
> 	s_copysign-ppc32.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-power6.S:
> 	Likewise.

Remove file?

> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S: Likewise.
> 	* sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile (sysdeps_calls):
> 	Remove s_copysign-power6 s_copysign-ppc64.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-power6.S:
> 	Likewise.

Remove file?

> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign-ppc64.S:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/s_copysignf.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/power6/fpu/s_copysignf.S: Likewise.

OK.

> +double
> +__copysign (double x, double y)
> +{
> +  return __builtin_copysign (x, y);
> +}
> +libm_alias_double (__copysign, copysign)
> +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
> +compat_symbol (libc, __copysign, copysignl, GLIBC_2_0);
> +#endif

OK.

> --- /dev/null
> +++ b/sysdeps/powerpc/fpu/s_copysignf.c
> @@ -0,0 +1,28 @@
> +/* Smallest integral value not less than argument.  PowerPC version.

Wrong description?

> +float
> +__copysignf (float x, float y)
> +{
> +  return __builtin_copysignf (x, y);
> +}
> +libm_alias_float (__copysign, copysign)

OK.

> -libm_alias_double (__copysign, copysign)
> -
> -/* It turns out that it's safe to use this code even for single-precision.  */
> -strong_alias(__copysign,__copysignf)
> -libm_alias_float (__copysign, copysign)
> -
> -#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
> -compat_symbol (libc, __copysign, copysignl, GLIBC_2_0)
> -#endif

OK. 

> --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign-ppc32.S
> +++ /dev/null
>
> [...]
>
> -#define __copysign __copysign_ppc32
> -#undef hidden_def
> -#define hidden_def(name)
> -  strong_alias (__copysign_ppc32, __GI___copysign)

OK.  Not in use with hidden_proto calls.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 11/28] benchtests: Add isnan/isinf/isfinite benchmark
  2019-03-29 13:35 ` [PATCH 11/28] benchtests: Add isnan/isinf/isfinite benchmark Adhemerval Zanella
@ 2019-06-05 22:45   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-05 22:45 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> 	* benchtests/Makefile (bench-math): Add isnan, isinf, and isfinite.
> 	(CFLAGS-bench-isnan.c, CFLAGS-bench-isinf.c,
> 	CFLAGS-bench-isfinite.c): New rule.
> 	* benchtests/isnan-input: New file.
> 	* benchtests/isinf-input: New file.
> 	* benchtests/isfinite-input: New file.

Looks good to me.  Thanks for doing this.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 12/28] math: Use wordsize-64 version for isnan
  2019-03-29 13:35 ` [PATCH 12/28] math: Use wordsize-64 version for isnan Adhemerval Zanella
@ 2019-06-05 22:45   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-05 22:45 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
>   - The resulting binary difference on 32 bits architecture is minimum
>     for the non hotspot symbol.

I don't actually understand what the impact on 32-bits platforms would
be, so I can't comment on that, but, if this patch turns out to be
problematic for 32-bits, we could patch sysdeps/ieee754/ldbl-opt files
to be mindful of __WORDSIZE and selectively include files from
sysdeps/ieee754/dbl-64 or sysdeps/ieee754/dbl-64/wordsize-64 (see
attached patch for an explanation of what I mean).

My point in raising this is that the subsequent patch [1] benefits from
this current patch (or, alternatively, from the attached patch, since
they have the same outcame, as expected).  So, if this patch gets
objections we could go with the alternative.

[1] https://sourceware.org/ml/libc-alpha/2019-03/msg00674.html

[-- Attachment #2: wordsize-test.patch --]
[-- Type: text/plain, Size: 1552 bytes --]

diff --git a/sysdeps/ieee754/ldbl-opt/s_finite.c b/sysdeps/ieee754/ldbl-opt/s_finite.c
index 7d3ab0068d..85ad5e625a 100644
--- a/sysdeps/ieee754/ldbl-opt/s_finite.c
+++ b/sysdeps/ieee754/ldbl-opt/s_finite.c
@@ -1,5 +1,10 @@
+#include <limits.h>
 #include <math_ldbl_opt.h>
+#if __WORDSIZE == 64
+#include <sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c>
+#else
 #include <sysdeps/ieee754/dbl-64/s_finite.c>
+#endif
 weak_alias (__finite, ___finite)
 #if IS_IN (libm)
 # if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
diff --git a/sysdeps/ieee754/ldbl-opt/s_isinf.c b/sysdeps/ieee754/ldbl-opt/s_isinf.c
index 1f760a0320..da5dc01601 100644
--- a/sysdeps/ieee754/ldbl-opt/s_isinf.c
+++ b/sysdeps/ieee754/ldbl-opt/s_isinf.c
@@ -1,5 +1,10 @@
+#include <limits.h>
 #include <math_ldbl_opt.h>
+#if __WORDSIZE == 64
+#include <sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c>
+#else
 #include <sysdeps/ieee754/dbl-64/s_isinf.c>
+#endif
 #if !IS_IN (libm)
 # if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
 compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
diff --git a/sysdeps/ieee754/ldbl-opt/s_isnan.c b/sysdeps/ieee754/ldbl-opt/s_isnan.c
index 33f57f1955..99ee75ce34 100644
--- a/sysdeps/ieee754/ldbl-opt/s_isnan.c
+++ b/sysdeps/ieee754/ldbl-opt/s_isnan.c
@@ -1,5 +1,10 @@
+#include <limits.h>
 #include <math_ldbl_opt.h>
+#if __WORDSIZE == 64
+#include <sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c>
+#else
 #include <sysdeps/ieee754/dbl-64/s_isnan.c>
+#endif
 #if !IS_IN (libm)
 # if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
 compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* Re: [PATCH 13/28] powerpc: Remove optimized isnan
  2019-03-29 13:35 ` [PATCH 13/28] powerpc: Remove optimized isnan Adhemerval Zanella
@ 2019-06-05 22:46   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-05 22:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
>   - The power7 uses ftdiv to optimize for some input patterns, but at
>     cost of others.  Comparing against generic C implementation built
>     for powerpc-linux-gnu-power4 (which uses the hp-timing support on
>     benchtests):
> 
>     [...]
> 
>     So it basically optimizes marginally for normal numbers while
>     increasing the latency for other kind of FP.

Fair enough.

> 	* sysdeps/powerpc/x/powerpc32/power4/fpu/multiarch/Makefile
                          ^
Typo in this ChangeLog path.

> 	(sysdeps_routines): Remove s_isnan-* objects.
         ^~~~~~~~~~~~~~~~
Missing mention to similar changes in libm-sysdep_routines.

Also, maybe mention the removal of 's_isnanf-*' files, too.  To make
clear that the removal of the float variants is intended.

I'm OK with the removal of the float variants, by the way.  And my
concerns about sysdeps/ieee754/dbl-64/wordsize-64/ files do not apply
here, because there is no sysdeps/ieee754/flt-32/wordsize-64/.


This patch looks good to me, provided we have the previous patch
(<https://sourceware.org/ml/libc-alpha/2019-03/msg00673.html>), or some
alternative implementation merged, as well.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 14/28] math: Use wordsize-64 version for isinf
  2019-03-29 13:35 ` [PATCH 14/28] math: Use wordsize-64 version for isinf Adhemerval Zanella
@ 2019-06-11 13:13   ` Gabriel F. T. Gomes
  2019-06-13  8:57   ` Szabolcs Nagy
  1 sibling, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-11 13:13 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
>   - The resulting binary difference on 32 bits architecture is minimum
>     for the non hotspot symbol.
> 
>   - It helps wordsize-64 architectures that use ldbl-opt.

Same comments I made for patch 12/28 [1], apply here.

[1] https://sourceware.org/ml/libc-alpha/2019-06/msg00085.html

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 15/28] powerpc: Remove optimized isinf
  2019-03-29 13:35 ` [PATCH 15/28] powerpc: Remove optimized isinf Adhemerval Zanella
@ 2019-06-11 13:45   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-11 13:45 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>
>   - The power7 uses ftdiv to optimize for some input pattern and branch
>     implementation for INF and denormal that does:
> 
>     return (ix & UINT64_C (0x7fffffffffffffff)) == UINT64_C (0x7ff0000000000000)
> 
>     Although it does show slight better latency than generic algorithm,
>     it is only for power7 and requires it to override it for power8.

Fair enough.

> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile usysdep_call):
                                                           ^
Typo................................................. here ^

> 	Likewise.
        ~~~~~~~~
"Remove s_isinf* objects"?

This patch looks good to me, provided we have the previous patch
(<https://sourceware.org/ml/libc-alpha/2019-03/msg00660.html>), or some
alternative implementation merged, as well.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 16/28] math: Use wordsize-64 version for finite
  2019-03-29 13:35 ` [PATCH 16/28] math: Use wordsize-64 version for finite Adhemerval Zanella
@ 2019-06-11 16:20   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-11 16:20 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
>   - The resulting binary difference on 32 bits architecture is minimum
>     for the non hotspot symbol.
> 
>   - It helps wordsize-64 architectures that use ldbl-opt.

Same comments I made for patch 12/28 [1], apply here.

[1] https://sourceware.org/ml/libc-alpha/2019-06/msg00085.html

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 17/28] powerpc: Remove optimized finite
  2019-03-29 13:35 ` [PATCH 17/28] powerpc: Remove optimized finite Adhemerval Zanella
@ 2019-06-11 18:08   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-11 18:08 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> The powerpc finite optimization do not show much gain:
> 
>   - The power7 uses ftdiv to optimize for some input patterns, but at
>     cost of others.  Comparing against generic C implementation built
>     for powerpc64-linux-gnu-power7 (--with-cpu=power7):
>
>     [...]
>
>     So it basically optimizes marginally for normal numbers while
>     increasing the latency for other kind of FP.

Fair enough.

> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
> 	(sysdeps_routines, libm-sysdep_routines): Remove s_finite*
> 	objects.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-power7.S:
> 	Remove file.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite-ppc32.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef-ppc32.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c: Likewise.
> 	* sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S: Likewise.
> 	* sysdeps/powerpc/powerpc32/power7/fpu/s_finitef.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile usysdep_call):
                                                           ^
Typo................................................. here ^
> 	Likewise.
"Remove s_finite* objects"?

This patch looks good to me.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 14/28] math: Use wordsize-64 version for isinf
  2019-03-29 13:35 ` [PATCH 14/28] math: Use wordsize-64 version for isinf Adhemerval Zanella
  2019-06-11 13:13   ` Gabriel F. T. Gomes
@ 2019-06-13  8:57   ` Szabolcs Nagy
  2019-06-13  9:11     ` Szabolcs Nagy
  1 sibling, 1 reply; 85+ messages in thread
From: Szabolcs Nagy @ 2019-06-13  8:57 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha@sourceware.org; +Cc: nd

On 29/03/2019 13:35, Adhemerval Zanella wrote:
>   - math.h will use compiler builtin for gcc 4.4+ when built without
>     -fsignaling-nans and the builtin is expanded inline for all
>     supported architectures.  As an example, there is no intra isnan
>     call on libm for the architecture I checked (x86, arm, aarch64,
>     and powerpc).
> 
>   - The resulting binary difference on 32 bits architecture is minimum
>     for the non hotspot symbol.
> 
>   - It helps wordsize-64 architectures that use ldbl-opt.
> 
>   - It add some code simplification with reduction of duplicated
>     implementations.
> 
> Checked on powerpc-linux-gnu (built without --with-cpu, with
> --with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
> powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
> and --disable-multi-arch).
> 
>         * sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Move to ...
>         * sysdeps/ieee754/dbl-64/s_isinf.c: ... here and format code.


on aarch64 buildbot i see

make[2]: *** No rule to make target '../sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c', needed by '/B/math/s_isinf.o'.
make[2]: *** No rule to make target '../sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c', needed by '/B/math/s_isnan.o'.
make[2]: *** No rule to make target '../sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c', needed by '/B/math/s_finite.o'.
make[2]: Target 'subdir_lib' not remade because of errors.
make[1]: *** [Makefile:259: math/subdir_lib] Error 2


^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 14/28] math: Use wordsize-64 version for isinf
  2019-06-13  8:57   ` Szabolcs Nagy
@ 2019-06-13  9:11     ` Szabolcs Nagy
  0 siblings, 0 replies; 85+ messages in thread
From: Szabolcs Nagy @ 2019-06-13  9:11 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha@sourceware.org; +Cc: nd

On 13/06/2019 09:57, Szabolcs Nagy wrote:
> on aarch64 buildbot i see
> 
> make[2]: *** No rule to make target '../sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c', needed by '/B/math/s_isinf.o'.
> make[2]: *** No rule to make target '../sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c', needed by '/B/math/s_isnan.o'.
> make[2]: *** No rule to make target '../sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c', needed by '/B/math/s_finite.o'.
> make[2]: Target 'subdir_lib' not remade because of errors.
> make[1]: *** [Makefile:259: math/subdir_lib] Error 2

sorry this is just a buildbot thing.

(it first runs the build in an unclean dir, which of
course had the deps for removed files, when it rerun
in a clean dir there was no failure.)


^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 18/28] powerpc: refactor powerpc64 lrint/lrintf/llrint/llrintf
  2019-03-29 13:35 ` [PATCH 18/28] powerpc: refactor powerpc64 lrint/lrintf/llrint/llrintf Adhemerval Zanella
@ 2019-06-13 19:30   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-13 19:30 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

Look good to me.  Thanks

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> The IFUNC support is also moved only to powerpc64 only, since for
> powerpc64le generic implementation resulting in optimized code.

Thanks for doing this.

For reference, here's the code that's generated on a powerpc64 build
targetting power4 (--with-cpu=power4 seems to be used on many distros):

  000000000007e880 <.__llrint_power8>:
    7e880:       fc 20 0e 5c     fctid   f1,f1
    7e884:       7c 23 00 66     mfvsrd  r3,vs1
    7e888:       4e 80 00 20     blr

  000000000007e8a0 <.__llrint_power6x>:
    7e8a0:       fc 20 0e 5c     fctid   f1,f1
    7e8a4:       7c 60 0d be     mftgpr  r3,f1
    7e8a8:       4e 80 00 20     blr

  000000000007e8c0 <.__llrint_ppc64>:
    7e8c0:       fc 20 0e 5c     fctid   f1,f1
    7e8c4:       d8 21 ff f8     stfd    f1,-8(r1)
    7e8c8:       60 00 00 00     nop
    7e8cc:       60 00 00 00     nop
    7e8d0:       60 00 00 00     nop
    7e8d4:       e8 61 ff f8     ld      r3,-8(r1)
    7e8d8:       4e 80 00 20     blr

powerpc64le doesn't suffer from this store-load scenario, since it is
only available for power8 and newer.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 20/28] powerpc: Refactor powerpc64 lround/lroundf/llround/llroundf
  2019-03-29 13:35 ` [PATCH 20/28] powerpc: Refactor powerpc64 lround/lroundf/llround/llroundf Adhemerval Zanella
@ 2019-06-13 19:30   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-13 19:30 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

I found just a small problem in this patch (see below).

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> The IFUNC support is also moved only to powerpc64 only, since for
> powerpc64le generic implementation resulting in optimized code.

Thanks, again.

For reference, again, a powerpc64 build produces:

  000000000007e6c0 <.__llround_power8>:
    7e6c0:       fc 20 0b 10     frin    f1,f1
    7e6c4:       fc 00 0e 5e     fctidz  f0,f1
    7e6c8:       7c 03 00 66     mfvsrd  r3,vs0
    7e6cc:       4e 80 00 20     blr

  000000000007e6e0 <.__llround_power6x>:
    7e6e0:       fc 20 0b 10     frin    f1,f1
    7e6e4:       fc 00 0e 5e     fctidz  f0,f1
    7e6e8:       7c 60 05 be     mftgpr  r3,f0
    7e6ec:       4e 80 00 20     blr

  000000000007e700 <.__llround_power5plus>:
    7e700:       fc 20 0b 10     frin    f1,f1
    7e704:       fc 00 0e 5e     fctidz  f0,f1
    7e708:       d8 01 ff f8     stfd    f0,-8(r1)
    7e70c:       60 00 00 00     nop
    7e710:       e8 61 ff f8     ld      r3,-8(r1)
    7e714:       4e 80 00 20     blr

  000000000007e730 <.__llround_ppc64>:
    7e730:       3d 22 ff fa     addis   r9,r2,-6
    7e734:       fc 00 0a 10     fabs    f0,f1
    7e738:       38 60 00 00     li      r3,0
    7e73c:       c1 89 a1 f4     lfs     f12,-24076(r9)
    7e740:       fc 00 60 00     fcmpu   cr0,f0,f12
    7e744:       4d 80 00 20     bltlr
    7e748:       3d 22 ff fa     addis   r9,r2,-6
    7e74c:       c1 49 6a 04     lfs     f10,27140(r9)
    7e750:       fc 00 50 00     fcmpu   cr0,f0,f10
    7e754:       40 80 00 2c     bge     7e780 <.__llround_ppc64+0x50>
    7e758:       fd 60 50 2a     fadd    f11,f0,f10
    7e75c:       fd 6b 50 28     fsub    f11,f11,f10
    7e760:       fc 00 58 00     fcmpu   cr0,f0,f11
    7e764:       41 82 00 1c     beq     7e780 <.__llround_ppc64+0x50>
    7e768:       3d 22 ff fa     addis   r9,r2,-6
    7e76c:       fc 00 60 2a     fadd    f0,f0,f12
    7e770:       c1 69 9c e0     lfs     f11,-25376(r9)
    7e774:       fc 01 58 00     fcmpu   cr0,f1,f11
    7e778:       41 80 00 28     blt     7e7a0 <.__llround_ppc64+0x70>
    7e77c:       fc 20 00 90     fmr     f1,f0
    7e780:       fc 20 0e 5e     fctidz  f1,f1
    7e784:       d8 21 ff f8     stfd    f1,-8(r1)
    7e788:       60 00 00 00     nop
    7e78c:       60 00 00 00     nop
    7e790:       60 00 00 00     nop
    7e794:       e8 61 ff f8     ld      r3,-8(r1)
    7e798:       4e 80 00 20     blr

> --- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
> +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile
>
> [...]
>  CFLAGS-s_roundf-power5+.c = -mcpu=power5+
>  CFLAGS-s_trunc-power5+.c = -mcpu=power5+
>  CFLAGS-s_truncf-power5+.c = -mcpu=power5+
> -CFLAGS-s_llrint-power8.c += -mcpu=power8
> -CFLAGS-s_llrint-power6x.c += -mcpu=power6x
> +CFLAGS-s_llround-power8.c += -mcpu=power8
> +CFLAGS-s_llround-power6x.c += -mcpu=power6x
> +CFLAGS-s_llround-power5+.c += -mcpu=power5+
>  endif

The removal of the two lines above is likely unintentional and wrong.

Looks good to me with that fixed.  Thanks.


Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 19/28] powerpc: Refactor powerpc32 lrint/lrintf/llrint/llrintf
  2019-03-29 13:35 ` [PATCH 19/28] powerpc: Refactor powerpc32 lrint/lrintf/llrint/llrintf Adhemerval Zanella
@ 2019-06-14 18:34   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-14 18:34 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> This patches consolidates all the powerpc llrint{f} implementations on
> the generic sysdeps/powerpc/powerpc32/fpu/s_llrint{f}.  The only missing
> optimization is the power6x one which I could not make GCC generates
> mftgpr for 32 bits output.

I see, and such optimization was never implemented anyway, so no harm done.

The patch looks good to me.  Thanks.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>


> +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-power6.c
> @@ -0,0 +1,2 @@
> +#define __llrint __llrint_power6
> +#include <sysdeps/powerpc/powerpc32/fpu/s_llrint.c>
>
> [...]
>
> +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint-ppc32.c
> @@ -0,0 +1,2 @@
> +#define __llrint __llrint_ppc32
> +#include <sysdeps/powerpc/powerpc32/fpu/s_llrint.c>

  00079d80 <__llrint_power6>:
    79d80:       94 21 ff f0     stwu    r1,-16(r1)
    79d84:       fc 20 0e 5c     fctid   f1,f1
    79d88:       d8 21 00 08     stfd    f1,8(r1)
    79d8c:       80 61 00 08     lwz     r3,8(r1)
    79d90:       80 81 00 0c     lwz     r4,12(r1)
    79d94:       38 21 00 10     addi    r1,r1,16
    79d98:       4e 80 00 20     blr

  00079da0 <__llrint_ppc32>:
    79da0:       94 21 ff f0     stwu    r1,-16(r1)
    79da4:       fc 20 0e 5c     fctid   f1,f1
    79da8:       d8 21 00 08     stfd    f1,8(r1)
->  79dac:       60 00 00 00     nop
    79db0:       80 61 00 08     lwz     r3,8(r1)
    79db4:       80 81 00 0c     lwz     r4,12(r1)
    79db8:       38 21 00 10     addi    r1,r1,16
    79dbc:       4e 80 00 20     blr

> -ENTRY (__llrint)
> -	CALL_MCOUNT
> -	stwu	r1,-16(r1)
> -	cfi_adjust_cfa_offset (16)
> -	fctid	fp13,fp1
> -	stfd	fp13,8(r1)
> -	nop	/* Insure the following load is in a different dispatch group */
> -	nop	/* to avoid pipe stall on POWER4&5.  */
> -	nop
> -	lwz	r3,8+HIWORD(r1)
> -	lwz	r4,8+LOWORD(r1)
> -	addi	r1,r1,16
> -	blr
> -	END (__llrint)

OK.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf
  2019-03-29 13:35 ` [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf Adhemerval Zanella
@ 2019-06-24 21:07   ` Gabriel F. T. Gomes
  2019-06-25 18:34     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-24 21:07 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> This patches consolidates all the powerpc llround{f} implementations on
> the generic sysdeps/powerpc/powerpc32/fpu/s_llround{f}.  The only missing
> optimization is the power6x one which I could not make GCC generates
> mftgpr for 32 bits output.

Similar to the llrint case, no harm done as such optimization wasn't
available, anyway.

> +  /* The barrier prevents compiler from optimizing it to llround when
> +     compiled with -fno-math-errno */
> +  math_opt_barrier (x);

I don't actually understand what this accomplishes, and I don't see any
difference in the code generated with and without this barrier (all my
builds have -fno-math-errno passed to the compiler).  Could you help me
understand this?

This is the code I get (with or without the barrier):

  00079dc0 <__llround_power6>:
    79dc0:       fc 20 0b 10     frin    f1,f1
    79dc4:       94 21 ff f0     stwu    r1,-16(r1)
    79dc8:       fc 00 0e 5e     fctidz  f0,f1
    79dcc:       d8 01 00 08     stfd    f0,8(r1)
    79dd0:       80 61 00 08     lwz     r3,8(r1)
    79dd4:       80 81 00 0c     lwz     r4,12(r1)
    79dd8:       38 21 00 10     addi    r1,r1,16
    79ddc:       4e 80 00 20     blr

  00079de0 <__llround_power5plus>:
    79de0:       94 21 ff f0     stwu    r1,-16(r1)
    79de4:       fc 20 0b 10     frin    f1,f1
    79de8:       fc 00 0e 5e     fctidz  f0,f1
    79dec:       d8 01 00 08     stfd    f0,8(r1)
    79df0:       60 00 00 00     nop
    79df4:       60 00 00 00     nop
    79df8:       60 00 00 00     nop
    79dfc:       80 61 00 08     lwz     r3,8(r1)
    79e00:       80 81 00 0c     lwz     r4,12(r1)
    79e04:       38 21 00 10     addi    r1,r1,16
    79e08:       4e 80 00 20     blr

> --- a/sysdeps/powerpc/powerpc32/fpu/s_llround.c
> +++ b/sysdeps/powerpc/powerpc32/fpu/s_llround.c
>
> [...]
>
> +    {
> +       /* IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
> +	  integer value, rounding halfway cases away from zero, regardless of
> +	  the current rounding mode."  However PowerPC Architecture defines
> +	  "round to Nearest" as "Choose the best approximation. In case of a
> +	  tie, choose the one that is even (least significant bit o).".
> +	  So we can't use the PowerPC "round to Nearest" mode. Instead we set
> +	  "round toward Zero" mode and round by adding +-0.5 before rounding
> +	  to the integer value.
> +  
   ~~
Two white-spaces here.

> --- a/sysdeps/powerpc/powerpc32/fpu/s_lround.S
> +++ /dev/null
>
> [...]
>
> -	fcmpu	cr5, fp1, fp9	/* if x >= 0x7fffffff.8p0  */
> -	fcmpu	cr1, fp1, fp8	/* if x <= -0x80000000.8p0  */

OK.  These have also been converted to c code in lround.c...

> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc32/fpu/s_lround.c
>
> [...]
>
> +  if (x >= 0x7fffffff.8p0 || x <= -0x80000000.8p0)
> +    x = (x < 0.0) ? -0x1p+52 : 0x1p+52;

... Here.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf
  2019-06-24 21:07   ` Gabriel F. T. Gomes
@ 2019-06-25 18:34     ` Adhemerval Zanella
  2019-06-25 18:44       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-06-25 18:34 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 24/06/2019 18:07, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>>
>> This patches consolidates all the powerpc llround{f} implementations on
>> the generic sysdeps/powerpc/powerpc32/fpu/s_llround{f}.  The only missing
>> optimization is the power6x one which I could not make GCC generates
>> mftgpr for 32 bits output.
> 
> Similar to the llrint case, no harm done as such optimization wasn't
> available, anyway.
> 
>> +  /* The barrier prevents compiler from optimizing it to llround when
>> +     compiled with -fno-math-errno */
>> +  math_opt_barrier (x);
> 
> I don't actually understand what this accomplishes, and I don't see any
> difference in the code generated with and without this barrier (all my
> builds have -fno-math-errno passed to the compiler).  Could you help me
> understand this?
> 
> This is the code I get (with or without the barrier):
> 
>   00079dc0 <__llround_power6>:
>     79dc0:       fc 20 0b 10     frin    f1,f1
>     79dc4:       94 21 ff f0     stwu    r1,-16(r1)
>     79dc8:       fc 00 0e 5e     fctidz  f0,f1
>     79dcc:       d8 01 00 08     stfd    f0,8(r1)
>     79dd0:       80 61 00 08     lwz     r3,8(r1)
>     79dd4:       80 81 00 0c     lwz     r4,12(r1)
>     79dd8:       38 21 00 10     addi    r1,r1,16
>     79ddc:       4e 80 00 20     blr
> 
>   00079de0 <__llround_power5plus>:
>     79de0:       94 21 ff f0     stwu    r1,-16(r1)
>     79de4:       fc 20 0b 10     frin    f1,f1
>     79de8:       fc 00 0e 5e     fctidz  f0,f1
>     79dec:       d8 01 00 08     stfd    f0,8(r1)
>     79df0:       60 00 00 00     nop
>     79df4:       60 00 00 00     nop
>     79df8:       60 00 00 00     nop
>     79dfc:       80 61 00 08     lwz     r3,8(r1)
>     79e00:       80 81 00 0c     lwz     r4,12(r1)
>     79e04:       38 21 00 10     addi    r1,r1,16
>     79e08:       4e 80 00 20     blr
> 
>> --- a/sysdeps/powerpc/powerpc32/fpu/s_llround.c
>> +++ b/sysdeps/powerpc/powerpc32/fpu/s_llround.c

Without math_opt_barrier I am seeing with gcc 8.2.1 20190214 
(--build=powerpc64-unknown-linux-gnu --host=powerpc64-unknown-linux-gnu 
--target=powerpc-glibc-linux-gnu no extra option, built with 
build-many-glibcs.py) I see using the flags:

powerpc-glibc-linux-gnu-gcc -mcpu=power4 ../sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c -c -std=gnu11 -fgnu89-inline  -g -O2 -mcpu=power4 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -mhard-float -Wstrict-prototypes -Wold-style-definition -fno-math-errno -mlong-double-128   -mcpu=power6       -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES 

---
__llround_power6:
.LVL0:
.LFB46: 
        .file 1 "../sysdeps/powerpc/powerpc32/fpu/s_llround.c"
        .loc 1 33 1 view -0
        .cfi_startproc
        .loc 1 35 3 view .LVU1
        .loc 1 35 10 is_stmt 0 view .LVU2
        b llround
.LVL1:  
        .loc 1 35 10 view .LVU3
        .cfi_endproc
---

This is because gcc transforms the "(long long int) round (x)" to llround
and thus creates a cyclic call (this is similar to aarch64 {l}lrint 
optimization).  

As a side note, the __builtin_llround for powerpc64 generates the expected
code.

>>
>> [...]
>>
>> +    {
>> +       /* IEEE 1003.1 lround function.  IEEE specifies "round to the nearest
>> +	  integer value, rounding halfway cases away from zero, regardless of
>> +	  the current rounding mode."  However PowerPC Architecture defines
>> +	  "round to Nearest" as "Choose the best approximation. In case of a
>> +	  tie, choose the one that is even (least significant bit o).".
>> +	  So we can't use the PowerPC "round to Nearest" mode. Instead we set
>> +	  "round toward Zero" mode and round by adding +-0.5 before rounding
>> +	  to the integer value.
>> +  
>    ~~
> Two white-spaces here.

Acked.

> 
>> --- a/sysdeps/powerpc/powerpc32/fpu/s_lround.S
>> +++ /dev/null
>>
>> [...]
>>
>> -	fcmpu	cr5, fp1, fp9	/* if x >= 0x7fffffff.8p0  */
>> -	fcmpu	cr1, fp1, fp8	/* if x <= -0x80000000.8p0  */
> 
> OK.  These have also been converted to c code in lround.c...
> 
>> --- /dev/null
>> +++ b/sysdeps/powerpc/powerpc32/fpu/s_lround.c
>>
>> [...]
>>
>> +  if (x >= 0x7fffffff.8p0 || x <= -0x80000000.8p0)
>> +    x = (x < 0.0) ? -0x1p+52 : 0x1p+52;
> 
> ... Here.
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf
  2019-06-25 18:34     ` Adhemerval Zanella
@ 2019-06-25 18:44       ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-25 18:44 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Tue, Jun 25 2019, Adhemerval Zanella wrote:
>
> Without math_opt_barrier I am seeing with gcc 8.2.1 20190214 
> (--build=powerpc64-unknown-linux-gnu --host=powerpc64-unknown-linux-gnu 
> --target=powerpc-glibc-linux-gnu no extra option, built with 
> build-many-glibcs.py) I see using the flags:
> 
> powerpc-glibc-linux-gnu-gcc -mcpu=power4 ../sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround-power6.c -c -std=gnu11 -fgnu89-inline  -g -O2 -mcpu=power4 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -mhard-float -Wstrict-prototypes -Wold-style-definition -fno-math-errno -mlong-double-128   -mcpu=power6       -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES 
> 
> ---
> __llround_power6:
> .LVL0:
> .LFB46: 
>         .file 1 "../sysdeps/powerpc/powerpc32/fpu/s_llround.c"
>         .loc 1 33 1 view -0
>         .cfi_startproc
>         .loc 1 35 3 view .LVU1
>         .loc 1 35 10 is_stmt 0 view .LVU2
>         b llround
> .LVL1:  
>         .loc 1 35 10 view .LVU3
>         .cfi_endproc
> ---

Oh, I see.  Thank you for the details! :)

The patch looks good to me.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 22/28] powerpc: Use generic e_expf
  2019-03-29 13:35 ` [PATCH 22/28] powerpc: Use generic e_expf Adhemerval Zanella
@ 2019-06-26 12:59   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-26 12:59 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
> 	(libm-sysdep_routines): Remove e_expf-power8 and expf-ppc64.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S: Remove
> 	file.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S: Likewise.
> 	* sysdeps/powerpc/powerpc64/power8/fpu/w_expf.c: Likewise.

Looks good to me.  Thanks.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 23/28] benchtests: hypot benchmark
  2019-03-29 13:35 ` [PATCH 23/28] benchtests: hypot benchmark Adhemerval Zanella
@ 2019-06-26 19:58   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-26 19:58 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>
> 	* benchtests/Makefile (bench-math): Add hypot.
> 	* benchtests/hypot-inputs: New file.

Looks good to me.  Thanks.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 24/28] powerpc: hypot refactor and optimization
  2019-03-29 13:35 ` [PATCH 24/28] powerpc: hypot refactor and optimization Adhemerval Zanella
  2019-04-01 20:14   ` Joseph Myers
@ 2019-06-26 19:59   ` Gabriel F. T. Gomes
  2019-07-08 15:37     ` Adhemerval Zanella
  1 sibling, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-06-26 19:59 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>
>   - Two reduntant checks (for y == 0 and y > two60factor && (x / y) > two60)
                                ~~~~~~
I don't understand why y == 0 is redundant.  It looks like an optimization
as much as the check for x > y * 0x1p+60.  Should we actually remove the
check for y == 0?

> 	* sysdeps/powerpc/fpu/e_hypot.c (two60, two500, two600, two1022,
> 	twoM500, twoM600, two60factor, pdnum): Remove.
> 	(TEST_INFO_NAN): Remove macro.

Missing mention to the removal of GET_TW0_HIGH_WORD?

> -  if (y == 0.0)
> -    return x;

As mentioned above, is it actually redundant?

> +  if (y <= 0x1.fffffffffffffp+963 && x > (y * 0x1p+60))
> +    return x + y;

OK.  Will not overflow.

Other than that the patch looks good to me.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 25/28] powerpc: Refactor modf{f}
  2019-03-29 13:35 ` [PATCH 25/28] powerpc: Refactor modf{f} Adhemerval Zanella
@ 2019-07-05  1:23   ` Gabriel F. T. Gomes
  2019-07-08 18:30     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-07-05  1:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> The modf{f} optimization is not an optimization for ISA 2.07+.  This
> patch move the IFUNC for powerpc64 only, move the power5+ to generic
> location, and include the generic implementation for ISA 2.07+.

Looks good to me. Thanks.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 26/28] benchtests: Add logb{f} benchmark
  2019-03-29 13:35 ` [PATCH 26/28] benchtests: Add logb{f} benchmark Adhemerval Zanella
@ 2019-07-05  1:23   ` Gabriel F. T. Gomes
  2019-07-08 18:31     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-07-05  1:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> 
> 	* benchtests/Makefile (bench-math): Add logb.
> 	* benchtests/logb-inputs: New file.
> 	* benchtests/logbf-inputs: New file.

Looks good to me.  Thanks.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 27/28] math: Use wordsize-64 version for s_logb
  2019-03-29 13:35 ` [PATCH 27/28] math: Use wordsize-64 version for s_logb Adhemerval Zanella
@ 2019-07-05  1:23   ` Gabriel F. T. Gomes
  2019-07-08 18:31     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-07-05  1:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>   - The resulting binary difference on 32 bits architecture is
>     minimum.  On i686-linux-gnu (with architecture optimization
>     routine removed) there is no different using logb benchtests

Based on our previous discussion, more specifically
<https://sourceware.org/ml/libc-alpha/2019-06/msg00223.html>,
this patch looks good to me.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 28/28] powerpc: refactor logb{f,l}
  2019-03-29 13:35 ` [PATCH 28/28] powerpc: refactor logb{f,l} Adhemerval Zanella
@ 2019-07-05  1:24   ` Gabriel F. T. Gomes
  2019-07-08 18:31     ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Gabriel F. T. Gomes @ 2019-07-05  1:24 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, Mar 29 2019, Adhemerval Zanella wrote:
> The power7 logb implementation does not show a performance gain on
> ISA 2.07+ chips with faster floating-point to GRP instructions
> (currently POWER8 and POWER9).

Looks good to me.  Thanks.

Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

> -  asm (
> -    "xxland %x0,%x1,%x2\n"
> -    "fcfid  %0,%0"
> -    : "=f" (ret)
> -    : "f" (x), "f" (mask.d));
> +  asm ("xxland %x0,%x1,%x2\n"
> +       "fcfid  %0,%0"
> +       : "=d" (ret)
> +       : "d" (x), "d" (0x7ff0000000000000ULL));

OK. I don't actually understand when the 'f' constraint is supposed to
be used, but 'd' looks good to me.

> -static const double two7m1    = -127.0;			/* -2**7 + 1  */
> [...]
> -  if (__builtin_expect (ret > -two7m1, 0))
> +  if (ret > 127.0)

OK. Double negative.

> --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
> +++ /dev/null

Hurray. :)

Thanks, Adhemerval.

Sorry for taking too long to review this patch set (I tried to review
them all before the freeze, but it wasn't so easy for me).

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 24/28] powerpc: hypot refactor and optimization
  2019-06-26 19:59   ` Gabriel F. T. Gomes
@ 2019-07-08 15:37     ` Adhemerval Zanella
  2019-07-08 18:30       ` Adhemerval Zanella
  0 siblings, 1 reply; 85+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 15:37 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 26/06/2019 16:59, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>>
>>   - Two reduntant checks (for y == 0 and y > two60factor && (x / y) > two60)
>                                 ~~~~~~
> I don't understand why y == 0 is redundant.  It looks like an optimization
> as much as the check for x > y * 0x1p+60.  Should we actually remove the
> check for y == 0?

Indeed redundant is not the correct word, it is an optimization. I have
reinstate it.

> 
>> 	* sysdeps/powerpc/fpu/e_hypot.c (two60, two500, two600, two1022,
>> 	twoM500, twoM600, two60factor, pdnum): Remove.
>> 	(TEST_INFO_NAN): Remove macro.
> 
> Missing mention to the removal of GET_TW0_HIGH_WORD?

Ack.

> 
>> -  if (y == 0.0)
>> -    return x;
> 
> As mentioned above, is it actually redundant?
> 
>> +  if (y <= 0x1.fffffffffffffp+963 && x > (y * 0x1p+60))
>> +    return x + y;
> 
> OK.  Will not overflow.
> 
> Other than that the patch looks good to me.
> 
> Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 24/28] powerpc: hypot refactor and optimization
  2019-07-08 15:37     ` Adhemerval Zanella
@ 2019-07-08 18:30       ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 18:30 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 08/07/2019 12:37, Adhemerval Zanella wrote:
> 
> 
> On 26/06/2019 16:59, Gabriel F. T. Gomes wrote:
>> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>>>
>>>   - Two reduntant checks (for y == 0 and y > two60factor && (x / y) > two60)
>>                                 ~~~~~~
>> I don't understand why y == 0 is redundant.  It looks like an optimization
>> as much as the check for x > y * 0x1p+60.  Should we actually remove the
>> check for y == 0?
> 
> Indeed redundant is not the correct word, it is an optimization. I have
> reinstate it.
> 
>>
>>> 	* sysdeps/powerpc/fpu/e_hypot.c (two60, two500, two600, two1022,
>>> 	twoM500, twoM600, two60factor, pdnum): Remove.
>>> 	(TEST_INFO_NAN): Remove macro.
>>
>> Missing mention to the removal of GET_TW0_HIGH_WORD?
> 
> Ack.
> 
>>
>>> -  if (y == 0.0)
>>> -    return x;
>>
>> As mentioned above, is it actually redundant?
>>
>>> +  if (y <= 0x1.fffffffffffffp+963 && x > (y * 0x1p+60))
>>> +    return x + y;
>>
>> OK.  Will not overflow.
>>
>> Other than that the patch looks good to me.
>>
>> Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
>>

If no one opposes it, I will commit this shortly.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 25/28] powerpc: Refactor modf{f}
  2019-07-05  1:23   ` Gabriel F. T. Gomes
@ 2019-07-08 18:30     ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 18:30 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 04/07/2019 22:23, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>> The modf{f} optimization is not an optimization for ISA 2.07+.  This
>> patch move the IFUNC for powerpc64 only, move the power5+ to generic
>> location, and include the generic implementation for ISA 2.07+.
> 
> Looks good to me. Thanks.
> 
> Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
> 

If no one opposes it, I will commit this shortly.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 26/28] benchtests: Add logb{f} benchmark
  2019-07-05  1:23   ` Gabriel F. T. Gomes
@ 2019-07-08 18:31     ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 18:31 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 04/07/2019 22:23, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>>
>> 	* benchtests/Makefile (bench-math): Add logb.
>> 	* benchtests/logb-inputs: New file.
>> 	* benchtests/logbf-inputs: New file.
> 
> Looks good to me.  Thanks.
> 
> Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
> 


If no one opposes it, I will commit this shortly.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 27/28] math: Use wordsize-64 version for s_logb
  2019-07-05  1:23   ` Gabriel F. T. Gomes
@ 2019-07-08 18:31     ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 18:31 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 04/07/2019 22:23, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>>   - The resulting binary difference on 32 bits architecture is
>>     minimum.  On i686-linux-gnu (with architecture optimization
>>     routine removed) there is no different using logb benchtests
> 
> Based on our previous discussion, more specifically
> <https://sourceware.org/ml/libc-alpha/2019-06/msg00223.html>,
> this patch looks good to me.
> 
> Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
> 


If no one opposes it, I will commit this shortly.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH 28/28] powerpc: refactor logb{f,l}
  2019-07-05  1:24   ` Gabriel F. T. Gomes
@ 2019-07-08 18:31     ` Adhemerval Zanella
  0 siblings, 0 replies; 85+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 18:31 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 04/07/2019 22:24, Gabriel F. T. Gomes wrote:
> On Fri, Mar 29 2019, Adhemerval Zanella wrote:
>> The power7 logb implementation does not show a performance gain on
>> ISA 2.07+ chips with faster floating-point to GRP instructions
>> (currently POWER8 and POWER9).
> 
> Looks good to me.  Thanks.
> 
> Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
> 
>> -  asm (
>> -    "xxland %x0,%x1,%x2\n"
>> -    "fcfid  %0,%0"
>> -    : "=f" (ret)
>> -    : "f" (x), "f" (mask.d));
>> +  asm ("xxland %x0,%x1,%x2\n"
>> +       "fcfid  %0,%0"
>> +       : "=d" (ret)
>> +       : "d" (x), "d" (0x7ff0000000000000ULL));
> 
> OK. I don't actually understand when the 'f' constraint is supposed to
> be used, but 'd' looks good to me.
> 
>> -static const double two7m1    = -127.0;			/* -2**7 + 1  */
>> [...]
>> -  if (__builtin_expect (ret > -two7m1, 0))
>> +  if (ret > 127.0)
> 
> OK. Double negative.
> 
>> --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
>> +++ /dev/null
> 
> Hurray. :)
> 
> Thanks, Adhemerval.
> 
> Sorry for taking too long to review this patch set (I tried to review
> them all before the freeze, but it wasn't so easy for me).
> 


If no one opposes it, I will commit this shortly.

^ permalink raw reply	[flat|nested] 85+ messages in thread

end of thread, other threads:[~2019-07-08 18:31 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 13:35 [PATCH 00/28] powerpc floating-point optimization refactor Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 01/28] powerpc: Use generic fabs{f} implementations Adhemerval Zanella
2019-04-01 20:04   ` Joseph Myers
2019-04-03  1:04     ` Adhemerval Zanella
2019-04-15 20:23       ` Gabriel F. T. Gomes
2019-04-15 21:32         ` Tulio Magno Quites Machado Filho
2019-04-17 17:08           ` Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 02/28] powerpc: fma using builtins Adhemerval Zanella
2019-04-01 20:05   ` Joseph Myers
2019-04-03  1:06     ` Adhemerval Zanella
2019-04-15 21:44       ` Gabriel F. T. Gomes
2019-04-17 21:10       ` Joseph Myers
2019-04-17 21:28         ` Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 03/28] powerpc: Remove power4 mpa optimization Adhemerval Zanella
2019-04-24 21:51   ` Gabriel F. T. Gomes
2019-04-25 12:19     ` Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 04/28] powerpc: ceil/ceilf refactor Adhemerval Zanella
2019-04-25  1:56   ` Gabriel F. T. Gomes
2019-04-25 21:58     ` Adhemerval Zanella
2019-05-02 18:41       ` Gabriel F. T. Gomes
2019-05-04 21:46         ` Gabriel F. T. Gomes
2019-05-06 12:22           ` Adhemerval Zanella
2019-05-09 19:56             ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 05/28] powerpc: floor/floorf refactor Adhemerval Zanella
2019-05-03 21:44   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 06/28] powerpc: round/roundf refactor Adhemerval Zanella
2019-05-04  1:10   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 07/28] powerpc: trunc/truncf refactor Adhemerval Zanella
2019-05-09 20:06   ` Gabriel F. T. Gomes
2019-05-09 20:54     ` Adhemerval Zanella
2019-05-09 21:36       ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 08/28] powerpc: generic nearbyint/nearbyintf Adhemerval Zanella
2019-05-27 20:42   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 09/28] powerpc: consolidate rint Adhemerval Zanella
2019-05-30 14:36   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 10/28] powerpc: copysign cleanup Adhemerval Zanella
2019-05-31 14:14   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 11/28] benchtests: Add isnan/isinf/isfinite benchmark Adhemerval Zanella
2019-06-05 22:45   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 12/28] math: Use wordsize-64 version for isnan Adhemerval Zanella
2019-06-05 22:45   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 13/28] powerpc: Remove optimized isnan Adhemerval Zanella
2019-06-05 22:46   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 14/28] math: Use wordsize-64 version for isinf Adhemerval Zanella
2019-06-11 13:13   ` Gabriel F. T. Gomes
2019-06-13  8:57   ` Szabolcs Nagy
2019-06-13  9:11     ` Szabolcs Nagy
2019-03-29 13:35 ` [PATCH 15/28] powerpc: Remove optimized isinf Adhemerval Zanella
2019-06-11 13:45   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 16/28] math: Use wordsize-64 version for finite Adhemerval Zanella
2019-06-11 16:20   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 17/28] powerpc: Remove optimized finite Adhemerval Zanella
2019-06-11 18:08   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 18/28] powerpc: refactor powerpc64 lrint/lrintf/llrint/llrintf Adhemerval Zanella
2019-06-13 19:30   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 19/28] powerpc: Refactor powerpc32 lrint/lrintf/llrint/llrintf Adhemerval Zanella
2019-06-14 18:34   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 20/28] powerpc: Refactor powerpc64 lround/lroundf/llround/llroundf Adhemerval Zanella
2019-06-13 19:30   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 21/28] powerpc: Refactor powerpc32 lround/lroundf/llround/llroundf Adhemerval Zanella
2019-06-24 21:07   ` Gabriel F. T. Gomes
2019-06-25 18:34     ` Adhemerval Zanella
2019-06-25 18:44       ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 22/28] powerpc: Use generic e_expf Adhemerval Zanella
2019-06-26 12:59   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 23/28] benchtests: hypot benchmark Adhemerval Zanella
2019-06-26 19:58   ` Gabriel F. T. Gomes
2019-03-29 13:35 ` [PATCH 24/28] powerpc: hypot refactor and optimization Adhemerval Zanella
2019-04-01 20:14   ` Joseph Myers
2019-04-03  1:08     ` Adhemerval Zanella
2019-06-26 19:59   ` Gabriel F. T. Gomes
2019-07-08 15:37     ` Adhemerval Zanella
2019-07-08 18:30       ` Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 25/28] powerpc: Refactor modf{f} Adhemerval Zanella
2019-07-05  1:23   ` Gabriel F. T. Gomes
2019-07-08 18:30     ` Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 26/28] benchtests: Add logb{f} benchmark Adhemerval Zanella
2019-07-05  1:23   ` Gabriel F. T. Gomes
2019-07-08 18:31     ` Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 27/28] math: Use wordsize-64 version for s_logb Adhemerval Zanella
2019-07-05  1:23   ` Gabriel F. T. Gomes
2019-07-08 18:31     ` Adhemerval Zanella
2019-03-29 13:35 ` [PATCH 28/28] powerpc: refactor logb{f,l} Adhemerval Zanella
2019-07-05  1:24   ` Gabriel F. T. Gomes
2019-07-08 18:31     ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).