diff mbox series

[v2] powerpc: Add log IFUNC multiarch support for POWER10

Message ID 20210408181511.28061-1-rzinsly@linux.ibm.com
State Committed
Commit 25cb72820ac40e73acf130edf97c895cf9b0b43a
Headers show
Series [v2] powerpc: Add log IFUNC multiarch support for POWER10 | expand

Commit Message

Raphael M Zinsly April 8, 2021, 6:15 p.m. UTC
Changes since v1:
         - Checks for the -mcpu=power10 support on configure instead of
           checking GCC's version.
         - Don't build __log_power10 without -mcpu=power10.

---8<---

Checked on ppc64le built without --with-cpu, with --with-cpu=power9
and with --disable-multi-arch.
---
 config.h.in                                   |  3 ++
 .../powerpc64/le/fpu/multiarch/Makefile       |  8 ++++
 .../powerpc64/le/fpu/multiarch/configure      | 33 +++++++++++++++++
 .../powerpc64/le/fpu/multiarch/configure.ac   | 14 +++++++
 .../le/fpu/multiarch/e_log-power10.c          |  4 ++
 .../powerpc64/le/fpu/multiarch/e_log-ppc64.c  |  4 ++
 .../powerpc64/le/fpu/multiarch/e_log.c        | 37 +++++++++++++++++++
 .../powerpc64/le/fpu/multiarch/w_log.c        |  1 +
 8 files changed, 104 insertions(+)
 create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
 create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
 create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
 create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
 create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
 create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c

Comments

Matheus Castanho April 22, 2021, 6:51 p.m. UTC | #1
Raphael Moreira Zinsly via Libc-alpha <libc-alpha@sourceware.org> writes:

> Changes since v1:
>          - Checks for the -mcpu=power10 support on configure instead of
>            checking GCC's version.
>          - Don't build __log_power10 without -mcpu=power10.
>
> ---8<---
>
> Checked on ppc64le built without --with-cpu, with --with-cpu=power9
> and with --disable-multi-arch.
> ---
>  config.h.in                                   |  3 ++
>  .../powerpc64/le/fpu/multiarch/Makefile       |  8 ++++
>  .../powerpc64/le/fpu/multiarch/configure      | 33 +++++++++++++++++
>  .../powerpc64/le/fpu/multiarch/configure.ac   | 14 +++++++
>  .../le/fpu/multiarch/e_log-power10.c          |  4 ++
>  .../powerpc64/le/fpu/multiarch/e_log-ppc64.c  |  4 ++
>  .../powerpc64/le/fpu/multiarch/e_log.c        | 37 +++++++++++++++++++
>  .../powerpc64/le/fpu/multiarch/w_log.c        |  1 +
>  8 files changed, 104 insertions(+)
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
>
> diff --git a/config.h.in b/config.h.in
> index ca1547ae67..14c3bf0f0d 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -23,6 +23,9 @@
>  /* On powerpc64, use @notoc.  */
>  #undef  USE_PPC64_NOTOC
>
> +/* On powerpc64, define if the compiler supports -mcpu=power10.  */
> +#undef USE_PPC64_MCPU_POWER10
> +
>  /* Define if _Unwind_Find_FDE should be exported from glibc.  */
>  #undef  EXPORT_UNWIND_FIND_FDE
>

Ok.

> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
> index 22252d9e0a..cc073b53d3 100644
> --- a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
> @@ -208,4 +208,12 @@ object-suffixes-left := $(all-object-suffixes)
>  include $(o-iterator)
>
>  endif # do_f128_multiarch
> +
> +libm-sysdep_routines += e_log-ppc64
> +
> +ifeq ($(mcpu-power10), yes)
> +libm-sysdep_routines += e_log-power10
> +CFLAGS-e_log-power10.c += -mcpu=power10
> +endif
> +
>  endif

Ok. Compiling __log_ppc64 with default flags and __log_power10 with
-mcpu=power10 based on flag defined in
sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure

> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
> new file mode 100644
> index 0000000000..4ca1d15833
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
> @@ -0,0 +1,33 @@
> +# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
> +
> +OLD_CFLAGS="$CFLAGS"
> +CFLAGS="$CFLAGS -mcpu=power10"
> +
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler supports -mcpu=power10" >&5
> +$as_echo_n "checking if the compiler supports -mcpu=power10... " >&6; }
> +if ${libc_cv_mcpu_power10+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  libc_cv_mcpu_power10=yes
> +else
> +  libc_cv_mcpu_power10=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mcpu_power10" >&5
> +$as_echo "$libc_cv_mcpu_power10" >&6; }
> +config_vars="$config_vars
> +mcpu-power10 = $libc_cv_mcpu_power10"
> +if test "$libc_cv_mcpu_power10" == "yes"; then :
> +
> +	$as_echo "#define USE_PPC64_MCPU_POWER10 1" >>confdefs.h
> +
> +fi
> +CFLAGS="$OLD_CFLAGS"
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
> new file mode 100644
> index 0000000000..ceb578cc59
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
> @@ -0,0 +1,14 @@
> +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> +
> +OLD_CFLAGS="$CFLAGS"
> +CFLAGS="$CFLAGS -mcpu=power10"
> +AC_CACHE_CHECK([if the compiler supports -mcpu=power10],
> +	       libc_cv_mcpu_power10, [
> +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
> +]])],
> +	       [libc_cv_mcpu_power10=yes],
> +	       [libc_cv_mcpu_power10=no])])
> +LIBC_CONFIG_VAR([mcpu-power10], [$libc_cv_mcpu_power10])
> +AS_IF([[test "$libc_cv_mcpu_power10" == "yes"]],[
> +	AC_DEFINE(USE_PPC64_MCPU_POWER10)])
> +CFLAGS="$OLD_CFLAGS"

Ok.

> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
> new file mode 100644
> index 0000000000..4226e07643
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
> @@ -0,0 +1,4 @@
> +#include <math.h>
> +
> +#define __log __log_power10
> +#include <sysdeps/ieee754/dbl-64/e_log.c>

Ok.

> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
> new file mode 100644
> index 0000000000..cb902d727a
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
> @@ -0,0 +1,4 @@
> +#include <math.h>
> +#define __log __log_ppc64
> +

Ok.

> +#include <sysdeps/ieee754/dbl-64/e_log.c>
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
> new file mode 100644
> index 0000000000..b7961096a5
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
> @@ -0,0 +1,37 @@
> +/* Multiple versions of IEEE 754 log.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <math.h>
> +#include "init-arch.h"
> +#include <libm-alias-finite.h>
> +
> +extern double __redirect_ieee754_log (double);
> +
> +extern __typeof (log) __log_ppc64 attribute_hidden;
> +#ifdef USE_PPC64_MCPU_POWER10
> +extern __typeof (log) __log_power10 attribute_hidden;
> +#endif
> +
> +libc_ifunc_redirected (__redirect_ieee754_log, __ieee754_log,
> +#ifdef USE_PPC64_MCPU_POWER10
> +	    (hwcap2 & PPC_FEATURE2_ARCH_3_1)
> +	    ? __log_power10 :
> +#endif
> +            __log_ppc64);
> +
> +libm_alias_finite (__ieee754_log, __log)

Ok. In case -mcpu=power10 is not supported, __log_ppc64 will be used.

> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
> new file mode 100644
> index 0000000000..9b2b018711
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
> @@ -0,0 +1 @@
> +#include <sysdeps/../math/w_log.c>

Also tested with and without multiarch and --with-cpu=power[9,10].

LGTM.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>

--
Matheus Castanho
Lucas A. M. Magalhaes April 26, 2021, 11:41 a.m. UTC | #2
LGTM. All tests with -mcpu=power10.

Quoting Raphael Moreira Zinsly via Libc-alpha (2021-04-08 15:15:11)
> Changes since v1:
>          - Checks for the -mcpu=power10 support on configure instead of
>            checking GCC's version.
>          - Don't build __log_power10 without -mcpu=power10.
> 
> ---8<---
> 
> Checked on ppc64le built without --with-cpu, with --with-cpu=power9
> and with --disable-multi-arch.
> ---
>  config.h.in                                   |  3 ++
>  .../powerpc64/le/fpu/multiarch/Makefile       |  8 ++++
>  .../powerpc64/le/fpu/multiarch/configure      | 33 +++++++++++++++++
>  .../powerpc64/le/fpu/multiarch/configure.ac   | 14 +++++++
>  .../le/fpu/multiarch/e_log-power10.c          |  4 ++
>  .../powerpc64/le/fpu/multiarch/e_log-ppc64.c  |  4 ++
>  .../powerpc64/le/fpu/multiarch/e_log.c        | 37 +++++++++++++++++++
>  .../powerpc64/le/fpu/multiarch/w_log.c        |  1 +
>  8 files changed, 104 insertions(+)
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
>  create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
> 
> diff --git a/config.h.in b/config.h.in
> index ca1547ae67..14c3bf0f0d 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -23,6 +23,9 @@
>  /* On powerpc64, use @notoc.  */
>  #undef  USE_PPC64_NOTOC
>  
> +/* On powerpc64, define if the compiler supports -mcpu=power10.  */
> +#undef USE_PPC64_MCPU_POWER10
> +
>  /* Define if _Unwind_Find_FDE should be exported from glibc.  */
>  #undef  EXPORT_UNWIND_FIND_FDE
>  
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
> index 22252d9e0a..cc073b53d3 100644
> --- a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
> @@ -208,4 +208,12 @@ object-suffixes-left := $(all-object-suffixes)
>  include $(o-iterator)
>  
>  endif # do_f128_multiarch
> +
> +libm-sysdep_routines += e_log-ppc64
> +
> +ifeq ($(mcpu-power10), yes)
> +libm-sysdep_routines += e_log-power10
> +CFLAGS-e_log-power10.c += -mcpu=power10
> +endif
> +
>  endif
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
> new file mode 100644
> index 0000000000..4ca1d15833
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
> @@ -0,0 +1,33 @@
> +# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
> +
> +OLD_CFLAGS="$CFLAGS"
> +CFLAGS="$CFLAGS -mcpu=power10"
> +
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler supports -mcpu=power10" >&5
> +$as_echo_n "checking if the compiler supports -mcpu=power10... " >&6; }
> +if ${libc_cv_mcpu_power10+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> +  libc_cv_mcpu_power10=yes
> +else
> +  libc_cv_mcpu_power10=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mcpu_power10" >&5
> +$as_echo "$libc_cv_mcpu_power10" >&6; }
> +config_vars="$config_vars
> +mcpu-power10 = $libc_cv_mcpu_power10"
> +if test "$libc_cv_mcpu_power10" == "yes"; then :
> +
> +       $as_echo "#define USE_PPC64_MCPU_POWER10 1" >>confdefs.h
> +
> +fi
> +CFLAGS="$OLD_CFLAGS"
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
> new file mode 100644
> index 0000000000..ceb578cc59
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
> @@ -0,0 +1,14 @@
> +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> +
> +OLD_CFLAGS="$CFLAGS"
> +CFLAGS="$CFLAGS -mcpu=power10"
> +AC_CACHE_CHECK([if the compiler supports -mcpu=power10],
> +              libc_cv_mcpu_power10, [
> +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
> +]])],
> +              [libc_cv_mcpu_power10=yes],
> +              [libc_cv_mcpu_power10=no])])
> +LIBC_CONFIG_VAR([mcpu-power10], [$libc_cv_mcpu_power10])
> +AS_IF([[test "$libc_cv_mcpu_power10" == "yes"]],[
> +       AC_DEFINE(USE_PPC64_MCPU_POWER10)])
> +CFLAGS="$OLD_CFLAGS"
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
> new file mode 100644
> index 0000000000..4226e07643
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
> @@ -0,0 +1,4 @@
> +#include <math.h>
> +
> +#define __log __log_power10
> +#include <sysdeps/ieee754/dbl-64/e_log.c>
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
> new file mode 100644
> index 0000000000..cb902d727a
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
> @@ -0,0 +1,4 @@
> +#include <math.h>
> +#define __log __log_ppc64
> +
> +#include <sysdeps/ieee754/dbl-64/e_log.c>
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
> new file mode 100644
> index 0000000000..b7961096a5
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
> @@ -0,0 +1,37 @@
> +/* Multiple versions of IEEE 754 log.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <math.h>
> +#include "init-arch.h"
> +#include <libm-alias-finite.h>
> +
> +extern double __redirect_ieee754_log (double);
> +
> +extern __typeof (log) __log_ppc64 attribute_hidden;
> +#ifdef USE_PPC64_MCPU_POWER10
> +extern __typeof (log) __log_power10 attribute_hidden;
> +#endif
> +
> +libc_ifunc_redirected (__redirect_ieee754_log, __ieee754_log,
> +#ifdef USE_PPC64_MCPU_POWER10
> +           (hwcap2 & PPC_FEATURE2_ARCH_3_1)
> +           ? __log_power10 :
> +#endif
> +            __log_ppc64);
> +
> +libm_alias_finite (__ieee754_log, __log)
> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
> new file mode 100644
> index 0000000000..9b2b018711
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
> @@ -0,0 +1 @@
> +#include <sysdeps/../math/w_log.c>
> -- 
> 2.29.2
>
Raphael M Zinsly April 26, 2021, 1:55 p.m. UTC | #3
I pushed as 25cb72820ac40e73acf130edf97c895cf9b0b43a thanks!
diff mbox series

Patch

diff --git a/config.h.in b/config.h.in
index ca1547ae67..14c3bf0f0d 100644
--- a/config.h.in
+++ b/config.h.in
@@ -23,6 +23,9 @@ 
 /* On powerpc64, use @notoc.  */
 #undef  USE_PPC64_NOTOC
 
+/* On powerpc64, define if the compiler supports -mcpu=power10.  */
+#undef USE_PPC64_MCPU_POWER10
+
 /* Define if _Unwind_Find_FDE should be exported from glibc.  */
 #undef  EXPORT_UNWIND_FIND_FDE
 
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
index 22252d9e0a..cc073b53d3 100644
--- a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
@@ -208,4 +208,12 @@  object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
 
 endif # do_f128_multiarch
+
+libm-sysdep_routines += e_log-ppc64
+
+ifeq ($(mcpu-power10), yes)
+libm-sysdep_routines += e_log-power10
+CFLAGS-e_log-power10.c += -mcpu=power10
+endif
+
 endif
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
new file mode 100644
index 0000000000..4ca1d15833
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure
@@ -0,0 +1,33 @@ 
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -mcpu=power10"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler supports -mcpu=power10" >&5
+$as_echo_n "checking if the compiler supports -mcpu=power10... " >&6; }
+if ${libc_cv_mcpu_power10+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_cv_mcpu_power10=yes
+else
+  libc_cv_mcpu_power10=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mcpu_power10" >&5
+$as_echo "$libc_cv_mcpu_power10" >&6; }
+config_vars="$config_vars
+mcpu-power10 = $libc_cv_mcpu_power10"
+if test "$libc_cv_mcpu_power10" == "yes"; then :
+
+	$as_echo "#define USE_PPC64_MCPU_POWER10 1" >>confdefs.h
+
+fi
+CFLAGS="$OLD_CFLAGS"
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
new file mode 100644
index 0000000000..ceb578cc59
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/configure.ac
@@ -0,0 +1,14 @@ 
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -mcpu=power10"
+AC_CACHE_CHECK([if the compiler supports -mcpu=power10],
+	       libc_cv_mcpu_power10, [
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+]])],
+	       [libc_cv_mcpu_power10=yes],
+	       [libc_cv_mcpu_power10=no])])
+LIBC_CONFIG_VAR([mcpu-power10], [$libc_cv_mcpu_power10])
+AS_IF([[test "$libc_cv_mcpu_power10" == "yes"]],[
+	AC_DEFINE(USE_PPC64_MCPU_POWER10)])
+CFLAGS="$OLD_CFLAGS"
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
new file mode 100644
index 0000000000..4226e07643
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-power10.c
@@ -0,0 +1,4 @@ 
+#include <math.h>
+
+#define __log __log_power10
+#include <sysdeps/ieee754/dbl-64/e_log.c>
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
new file mode 100644
index 0000000000..cb902d727a
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log-ppc64.c
@@ -0,0 +1,4 @@ 
+#include <math.h>
+#define __log __log_ppc64
+
+#include <sysdeps/ieee754/dbl-64/e_log.c>
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
new file mode 100644
index 0000000000..b7961096a5
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/e_log.c
@@ -0,0 +1,37 @@ 
+/* Multiple versions of IEEE 754 log.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include "init-arch.h"
+#include <libm-alias-finite.h>
+
+extern double __redirect_ieee754_log (double);
+
+extern __typeof (log) __log_ppc64 attribute_hidden;
+#ifdef USE_PPC64_MCPU_POWER10
+extern __typeof (log) __log_power10 attribute_hidden;
+#endif
+
+libc_ifunc_redirected (__redirect_ieee754_log, __ieee754_log,
+#ifdef USE_PPC64_MCPU_POWER10
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1)
+	    ? __log_power10 :
+#endif
+            __log_ppc64);
+
+libm_alias_finite (__ieee754_log, __log)
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
new file mode 100644
index 0000000000..9b2b018711
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_log.c
@@ -0,0 +1 @@ 
+#include <sysdeps/../math/w_log.c>