public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy
@ 2021-05-03 19:59 Raoni Fassina Firmino
  2021-05-04 13:31 ` Lucas A. M. Magalhaes
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Raoni Fassina Firmino @ 2021-05-03 19:59 UTC (permalink / raw)
  To: libc-alpha; +Cc: tuliom, lamm

The hwcap2 check for the aforementioned functions should check for
both PPC_FEATURE2_ARCH_3_1 and PPC_FEATURE2_HAS_ISEL but was
mistakenly checking for any one of them, enabling isa 3.1 version of
the functions in incompatible processors, like POWER8.
---
 sysdeps/powerpc/powerpc64/multiarch/bcopy.c   |  8 ++++----
 sysdeps/powerpc/powerpc64/multiarch/bzero.c   |  3 ++-
 .../powerpc64/multiarch/ifunc-impl-list.c     | 20 +++++++++----------
 sysdeps/powerpc/powerpc64/multiarch/memmove.c |  8 ++++----
 sysdeps/powerpc/powerpc64/multiarch/memset.c  |  3 ++-
 5 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
index 2840b17fdfd3..02eb1e6a9f66 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
@@ -28,10 +28,10 @@ extern __typeof (bcopy) __bcopy_power10 attribute_hidden;
 
 libc_ifunc (bcopy,
 #ifdef __LITTLE_ENDIAN__
-	     hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
-		       PPC_FEATURE2_HAS_ISEL)
-	     && (hwcap & PPC_FEATURE_HAS_VSX)
-	     ? __bcopy_power10 :
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
+	     && hwcap & PPC_FEATURE_HAS_VSX)
+	    ? __bcopy_power10 :
 #endif
             (hwcap & PPC_FEATURE_HAS_VSX)
             ? __bcopy_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/bzero.c b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
index 50a5320c6650..660d7dc686ec 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bzero.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
@@ -33,7 +33,8 @@ extern __typeof (bzero) __bzero_power10 attribute_hidden;
 
 libc_ifunc (__bzero,
 # ifdef __LITTLE_ENDIAN__
-	    (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
 	     && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __bzero_power10 :
 # endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index 49d9a33e65fe..b123c6a3d328 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -75,9 +75,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
   IFUNC_IMPL (i, name, memmove,
 #ifdef __LITTLE_ENDIAN__
 	      IFUNC_IMPL_ADD (array, i, memmove,
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
-					PPC_FEATURE2_HAS_ISEL)
-			      && (hwcap & PPC_FEATURE_HAS_VSX),
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
+			      && hwcap & PPC_FEATURE_HAS_VSX,
 			      __memmove_power10)
 #endif
 	      IFUNC_IMPL_ADD (array, i, memmove, hwcap & PPC_FEATURE_HAS_VSX,
@@ -88,8 +88,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
   IFUNC_IMPL (i, name, memset,
 #ifdef __LITTLE_ENDIAN__
 	      IFUNC_IMPL_ADD (array, i, memset,
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
-					PPC_FEATURE2_HAS_ISEL)
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
 			      && hwcap & PPC_FEATURE_HAS_VSX,
 			      __memset_power10)
 #endif
@@ -196,8 +196,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
   IFUNC_IMPL (i, name, bzero,
 #ifdef __LITTLE_ENDIAN__
 	      IFUNC_IMPL_ADD (array, i, bzero,
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
-					PPC_FEATURE2_HAS_ISEL)
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
 			      && hwcap & PPC_FEATURE_HAS_VSX,
 			      __bzero_power10)
 #endif
@@ -215,9 +215,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
   IFUNC_IMPL (i, name, bcopy,
 #ifdef __LITTLE_ENDIAN__
 	      IFUNC_IMPL_ADD (array, i, bcopy,
-			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
-					PPC_FEATURE2_HAS_ISEL)
-			      && (hwcap & PPC_FEATURE_HAS_VSX),
+			      hwcap2 & PPC_FEATURE2_ARCH_3_1
+			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
+			      && hwcap & PPC_FEATURE_HAS_VSX,
 			      __bcopy_power10)
 #endif
 	      IFUNC_IMPL_ADD (array, i, bcopy, hwcap & PPC_FEATURE_HAS_VSX,
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memmove.c b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
index 420c2f279af3..637b2cbf7f35 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memmove.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
@@ -36,10 +36,10 @@ extern __typeof (__redirect_memmove) __memmove_power10 attribute_hidden;
 
 libc_ifunc (__libc_memmove,
 #ifdef __LITTLE_ENDIAN__
-	     hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
-		       PPC_FEATURE2_HAS_ISEL)
-	     && (hwcap & PPC_FEATURE_HAS_VSX)
-	     ? __memmove_power10 :
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
+	     && hwcap & PPC_FEATURE_HAS_VSX)
+	    ? __memmove_power10 :
 #endif
 		     (hwcap & PPC_FEATURE_HAS_VSX)
 		     ? __memmove_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memset.c b/sysdeps/powerpc/powerpc64/multiarch/memset.c
index 6562646dffcf..5994bf02e622 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memset.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memset.c
@@ -41,7 +41,8 @@ extern __typeof (__redirect_memset) __memset_power10 attribute_hidden;
    ifunc symbol properly.  */
 libc_ifunc (__libc_memset,
 # ifdef __LITTLE_ENDIAN__
-	    (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
+	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
 	     && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __memset_power10 :
 # endif
-- 
2.26.2


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

* Re: [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy
  2021-05-03 19:59 [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy Raoni Fassina Firmino
@ 2021-05-04 13:31 ` Lucas A. M. Magalhaes
  2021-05-04 17:48 ` Raphael M Zinsly
  2021-05-07 20:04 ` Tulio Magno Quites Machado Filho
  2 siblings, 0 replies; 5+ messages in thread
From: Lucas A. M. Magalhaes @ 2021-05-04 13:31 UTC (permalink / raw)
  To: Raoni Fassina Firmino, libc-alpha; +Cc: tuliom

Raoni, LGTM! Tests pass with --mcpu=power10.

Quoting Raoni Fassina Firmino (2021-05-03 16:59:35)
> The hwcap2 check for the aforementioned functions should check for
> both PPC_FEATURE2_ARCH_3_1 and PPC_FEATURE2_HAS_ISEL but was
> mistakenly checking for any one of them, enabling isa 3.1 version of
> the functions in incompatible processors, like POWER8.
> ---
>  sysdeps/powerpc/powerpc64/multiarch/bcopy.c   |  8 ++++----
>  sysdeps/powerpc/powerpc64/multiarch/bzero.c   |  3 ++-
>  .../powerpc64/multiarch/ifunc-impl-list.c     | 20 +++++++++----------
>  sysdeps/powerpc/powerpc64/multiarch/memmove.c |  8 ++++----
>  sysdeps/powerpc/powerpc64/multiarch/memset.c  |  3 ++-
>  5 files changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
> index 2840b17fdfd3..02eb1e6a9f66 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
> @@ -28,10 +28,10 @@ extern __typeof (bcopy) __bcopy_power10 attribute_hidden;
>  
>  libc_ifunc (bcopy,
>  #ifdef __LITTLE_ENDIAN__
> -            hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -                      PPC_FEATURE2_HAS_ISEL)
> -            && (hwcap & PPC_FEATURE_HAS_VSX)
> -            ? __bcopy_power10 :
> +           (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +            && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +            && hwcap & PPC_FEATURE_HAS_VSX)
> +           ? __bcopy_power10 :
>  #endif
>              (hwcap & PPC_FEATURE_HAS_VSX)
>              ? __bcopy_power7
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/bzero.c b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
> index 50a5320c6650..660d7dc686ec 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/bzero.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
> @@ -33,7 +33,8 @@ extern __typeof (bzero) __bzero_power10 attribute_hidden;
>  
>  libc_ifunc (__bzero,
>  # ifdef __LITTLE_ENDIAN__
> -           (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
> +           (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +            && hwcap2 & PPC_FEATURE2_HAS_ISEL
>              && hwcap & PPC_FEATURE_HAS_VSX)
>             ? __bzero_power10 :
>  # endif
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
> index 49d9a33e65fe..b123c6a3d328 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
> @@ -75,9 +75,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>    IFUNC_IMPL (i, name, memmove,
>  #ifdef __LITTLE_ENDIAN__
>               IFUNC_IMPL_ADD (array, i, memmove,
> -                             hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -                                       PPC_FEATURE2_HAS_ISEL)
> -                             && (hwcap & PPC_FEATURE_HAS_VSX),
> +                             hwcap2 & PPC_FEATURE2_ARCH_3_1
> +                             && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +                             && hwcap & PPC_FEATURE_HAS_VSX,
>                               __memmove_power10)
>  #endif
>               IFUNC_IMPL_ADD (array, i, memmove, hwcap & PPC_FEATURE_HAS_VSX,
> @@ -88,8 +88,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>    IFUNC_IMPL (i, name, memset,
>  #ifdef __LITTLE_ENDIAN__
>               IFUNC_IMPL_ADD (array, i, memset,
> -                             hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -                                       PPC_FEATURE2_HAS_ISEL)
> +                             hwcap2 & PPC_FEATURE2_ARCH_3_1
> +                             && hwcap2 & PPC_FEATURE2_HAS_ISEL
>                               && hwcap & PPC_FEATURE_HAS_VSX,
>                               __memset_power10)
>  #endif
> @@ -196,8 +196,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>    IFUNC_IMPL (i, name, bzero,
>  #ifdef __LITTLE_ENDIAN__
>               IFUNC_IMPL_ADD (array, i, bzero,
> -                             hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -                                       PPC_FEATURE2_HAS_ISEL)
> +                             hwcap2 & PPC_FEATURE2_ARCH_3_1
> +                             && hwcap2 & PPC_FEATURE2_HAS_ISEL
>                               && hwcap & PPC_FEATURE_HAS_VSX,
>                               __bzero_power10)
>  #endif
> @@ -215,9 +215,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>    IFUNC_IMPL (i, name, bcopy,
>  #ifdef __LITTLE_ENDIAN__
>               IFUNC_IMPL_ADD (array, i, bcopy,
> -                             hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -                                       PPC_FEATURE2_HAS_ISEL)
> -                             && (hwcap & PPC_FEATURE_HAS_VSX),
> +                             hwcap2 & PPC_FEATURE2_ARCH_3_1
> +                             && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +                             && hwcap & PPC_FEATURE_HAS_VSX,
>                               __bcopy_power10)
>  #endif
>               IFUNC_IMPL_ADD (array, i, bcopy, hwcap & PPC_FEATURE_HAS_VSX,
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/memmove.c b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
> index 420c2f279af3..637b2cbf7f35 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/memmove.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
> @@ -36,10 +36,10 @@ extern __typeof (__redirect_memmove) __memmove_power10 attribute_hidden;
>  
>  libc_ifunc (__libc_memmove,
>  #ifdef __LITTLE_ENDIAN__
> -            hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -                      PPC_FEATURE2_HAS_ISEL)
> -            && (hwcap & PPC_FEATURE_HAS_VSX)
> -            ? __memmove_power10 :
> +           (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +            && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +            && hwcap & PPC_FEATURE_HAS_VSX)
> +           ? __memmove_power10 :
>  #endif
>                      (hwcap & PPC_FEATURE_HAS_VSX)
>                      ? __memmove_power7
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/memset.c b/sysdeps/powerpc/powerpc64/multiarch/memset.c
> index 6562646dffcf..5994bf02e622 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/memset.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/memset.c
> @@ -41,7 +41,8 @@ extern __typeof (__redirect_memset) __memset_power10 attribute_hidden;
>     ifunc symbol properly.  */
>  libc_ifunc (__libc_memset,
>  # ifdef __LITTLE_ENDIAN__
> -           (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
> +           (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +            && hwcap2 & PPC_FEATURE2_HAS_ISEL
>              && hwcap & PPC_FEATURE_HAS_VSX)
>             ? __memset_power10 :
>  # endif
> -- 
> 2.26.2
>

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

* Re: [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy
  2021-05-03 19:59 [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy Raoni Fassina Firmino
  2021-05-04 13:31 ` Lucas A. M. Magalhaes
@ 2021-05-04 17:48 ` Raphael M Zinsly
  2021-05-06 14:09   ` Raoni Fassina Firmino
  2021-05-07 20:04 ` Tulio Magno Quites Machado Filho
  2 siblings, 1 reply; 5+ messages in thread
From: Raphael M Zinsly @ 2021-05-04 17:48 UTC (permalink / raw)
  To: libc-alpha, Raoni Fassina Firmino

The patch LGTM but I think it would improve readbility if you use more 
parentheses in the multiarch files e.g.:

	(hwcap2 & PPC_FEATURE2_ARCH_3_1)
	     && (hwcap2 & PPC_FEATURE2_HAS_ISEL)
	     && (hwcap & PPC_FEATURE_HAS_VSX)
	    ? __bcopy_power10 :


On 03/05/2021 16:59, Raoni Fassina Firmino via Libc-alpha wrote:
> The hwcap2 check for the aforementioned functions should check for
> both PPC_FEATURE2_ARCH_3_1 and PPC_FEATURE2_HAS_ISEL but was
> mistakenly checking for any one of them, enabling isa 3.1 version of
> the functions in incompatible processors, like POWER8.
> ---
>   sysdeps/powerpc/powerpc64/multiarch/bcopy.c   |  8 ++++----
>   sysdeps/powerpc/powerpc64/multiarch/bzero.c   |  3 ++-
>   .../powerpc64/multiarch/ifunc-impl-list.c     | 20 +++++++++----------
>   sysdeps/powerpc/powerpc64/multiarch/memmove.c |  8 ++++----
>   sysdeps/powerpc/powerpc64/multiarch/memset.c  |  3 ++-
>   5 files changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
> index 2840b17fdfd3..02eb1e6a9f66 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/bcopy.c
> @@ -28,10 +28,10 @@ extern __typeof (bcopy) __bcopy_power10 attribute_hidden;
> 
>   libc_ifunc (bcopy,
>   #ifdef __LITTLE_ENDIAN__
> -	     hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -		       PPC_FEATURE2_HAS_ISEL)
> -	     && (hwcap & PPC_FEATURE_HAS_VSX)
> -	     ? __bcopy_power10 :
> +	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +	     && hwcap & PPC_FEATURE_HAS_VSX)
> +	    ? __bcopy_power10 :
>   #endif
>               (hwcap & PPC_FEATURE_HAS_VSX)
>               ? __bcopy_power7
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/bzero.c b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
> index 50a5320c6650..660d7dc686ec 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/bzero.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
> @@ -33,7 +33,8 @@ extern __typeof (bzero) __bzero_power10 attribute_hidden;
> 
>   libc_ifunc (__bzero,
>   # ifdef __LITTLE_ENDIAN__
> -	    (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
> +	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
>   	     && hwcap & PPC_FEATURE_HAS_VSX)
>   	    ? __bzero_power10 :
>   # endif
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
> index 49d9a33e65fe..b123c6a3d328 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
> @@ -75,9 +75,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>     IFUNC_IMPL (i, name, memmove,
>   #ifdef __LITTLE_ENDIAN__
>   	      IFUNC_IMPL_ADD (array, i, memmove,
> -			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -					PPC_FEATURE2_HAS_ISEL)
> -			      && (hwcap & PPC_FEATURE_HAS_VSX),
> +			      hwcap2 & PPC_FEATURE2_ARCH_3_1
> +			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +			      && hwcap & PPC_FEATURE_HAS_VSX,
>   			      __memmove_power10)
>   #endif
>   	      IFUNC_IMPL_ADD (array, i, memmove, hwcap & PPC_FEATURE_HAS_VSX,
> @@ -88,8 +88,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>     IFUNC_IMPL (i, name, memset,
>   #ifdef __LITTLE_ENDIAN__
>   	      IFUNC_IMPL_ADD (array, i, memset,
> -			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -					PPC_FEATURE2_HAS_ISEL)
> +			      hwcap2 & PPC_FEATURE2_ARCH_3_1
> +			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
>   			      && hwcap & PPC_FEATURE_HAS_VSX,
>   			      __memset_power10)
>   #endif
> @@ -196,8 +196,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>     IFUNC_IMPL (i, name, bzero,
>   #ifdef __LITTLE_ENDIAN__
>   	      IFUNC_IMPL_ADD (array, i, bzero,
> -			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -					PPC_FEATURE2_HAS_ISEL)
> +			      hwcap2 & PPC_FEATURE2_ARCH_3_1
> +			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
>   			      && hwcap & PPC_FEATURE_HAS_VSX,
>   			      __bzero_power10)
>   #endif
> @@ -215,9 +215,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>     IFUNC_IMPL (i, name, bcopy,
>   #ifdef __LITTLE_ENDIAN__
>   	      IFUNC_IMPL_ADD (array, i, bcopy,
> -			      hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -					PPC_FEATURE2_HAS_ISEL)
> -			      && (hwcap & PPC_FEATURE_HAS_VSX),
> +			      hwcap2 & PPC_FEATURE2_ARCH_3_1
> +			      && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +			      && hwcap & PPC_FEATURE_HAS_VSX,
>   			      __bcopy_power10)
>   #endif
>   	      IFUNC_IMPL_ADD (array, i, bcopy, hwcap & PPC_FEATURE_HAS_VSX,
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/memmove.c b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
> index 420c2f279af3..637b2cbf7f35 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/memmove.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
> @@ -36,10 +36,10 @@ extern __typeof (__redirect_memmove) __memmove_power10 attribute_hidden;
> 
>   libc_ifunc (__libc_memmove,
>   #ifdef __LITTLE_ENDIAN__
> -	     hwcap2 & (PPC_FEATURE2_ARCH_3_1 |
> -		       PPC_FEATURE2_HAS_ISEL)
> -	     && (hwcap & PPC_FEATURE_HAS_VSX)
> -	     ? __memmove_power10 :
> +	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
> +	     && hwcap & PPC_FEATURE_HAS_VSX)
> +	    ? __memmove_power10 :
>   #endif
>   		     (hwcap & PPC_FEATURE_HAS_VSX)
>   		     ? __memmove_power7
> diff --git a/sysdeps/powerpc/powerpc64/multiarch/memset.c b/sysdeps/powerpc/powerpc64/multiarch/memset.c
> index 6562646dffcf..5994bf02e622 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/memset.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/memset.c
> @@ -41,7 +41,8 @@ extern __typeof (__redirect_memset) __memset_power10 attribute_hidden;
>      ifunc symbol properly.  */
>   libc_ifunc (__libc_memset,
>   # ifdef __LITTLE_ENDIAN__
> -	    (hwcap2 & (PPC_FEATURE2_ARCH_3_1 | PPC_FEATURE2_HAS_ISEL)
> +	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
> +	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
>   	     && hwcap & PPC_FEATURE_HAS_VSX)
>   	    ? __memset_power10 :
>   # endif
> 

-- 
Raphael Moreira Zinsly

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

* Re: [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy
  2021-05-04 17:48 ` Raphael M Zinsly
@ 2021-05-06 14:09   ` Raoni Fassina Firmino
  0 siblings, 0 replies; 5+ messages in thread
From: Raoni Fassina Firmino @ 2021-05-06 14:09 UTC (permalink / raw)
  To: Raphael M Zinsly; +Cc: libc-alpha

On Tue, May 04, 2021 at 02:48:06PM -0300, Raphael M Zinsly wrote:
> The patch LGTM but I think it would improve readbility if you use more
> parentheses in the multiarch files e.g.:
> 
> 	(hwcap2 & PPC_FEATURE2_ARCH_3_1)
> 	     && (hwcap2 & PPC_FEATURE2_HAS_ISEL)
> 	     && (hwcap & PPC_FEATURE_HAS_VSX)
> 	    ? __bcopy_power10 :

I tried to follow the parentheses style of the surround code, but some
use parentheses for each hwcap sub-expression, some don't. IMHO less
parentheses are more readable, but I don't have strong opinion about it
and can change it if you feel strong about it.


o/
Raoni

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

* Re: [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy
  2021-05-03 19:59 [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy Raoni Fassina Firmino
  2021-05-04 13:31 ` Lucas A. M. Magalhaes
  2021-05-04 17:48 ` Raphael M Zinsly
@ 2021-05-07 20:04 ` Tulio Magno Quites Machado Filho
  2 siblings, 0 replies; 5+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2021-05-07 20:04 UTC (permalink / raw)
  To: Raoni Fassina Firmino, libc-alpha

Raoni Fassina Firmino via Libc-alpha <libc-alpha@sourceware.org> writes:

> The hwcap2 check for the aforementioned functions should check for
> both PPC_FEATURE2_ARCH_3_1 and PPC_FEATURE2_HAS_ISEL but was
> mistakenly checking for any one of them, enabling isa 3.1 version of
> the functions in incompatible processors, like POWER8.

LGTM.  This time, tested on POWER8 too.

Pushed as 17a73a6d8b4c46f3e87fc53c7c25fa7cec01d707.

Thank you!

-- 
Tulio Magno

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

end of thread, other threads:[~2021-05-07 20:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 19:59 [PATCH] powerpc64le: Fix ifunc selection for memset, memmove, bzero and bcopy Raoni Fassina Firmino
2021-05-04 13:31 ` Lucas A. M. Magalhaes
2021-05-04 17:48 ` Raphael M Zinsly
2021-05-06 14:09   ` Raoni Fassina Firmino
2021-05-07 20:04 ` Tulio Magno Quites Machado Filho

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).