diff mbox series

[3/3] powerpc64: Add checks for Altivec and VSX in ifunc selection

Message ID 20210706105107.1866836-3-anton@ozlabs.org
State New
Headers show
Series [1/3] powerpc64: Replace some PPC_FEATURE_HAS_VSX with PPC_FEATURE_ARCH_2_06 | expand

Checks

Context Check Description
dj/TryBot-32bit success Build for i686
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Anton Blanchard July 6, 2021, 10:51 a.m. UTC
We'd like to support processors without Altivec or VSX, so check
the relevant hwcap bits before selecting them.
---
 sysdeps/powerpc/powerpc64/multiarch/bzero.c      | 6 ++++--
 sysdeps/powerpc/powerpc64/multiarch/memchr.c     | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/memcmp.c     | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/memcpy.c     | 7 +++++--
 sysdeps/powerpc/powerpc64/multiarch/memmove.c    | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/mempcpy.c    | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/memrchr.c    | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/memset.c     | 1 +
 sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c  | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/stpcpy.c     | 9 ++++++---
 sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strcasestr.c | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strcat.c     | 6 ++++--
 sysdeps/powerpc/powerpc64/multiarch/strchr.c     | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strchrnul.c  | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strcmp.c     | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strcpy.c     | 9 ++++++---
 sysdeps/powerpc/powerpc64/multiarch/strcspn.c    | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strlen.c     | 9 ++++++---
 sysdeps/powerpc/powerpc64/multiarch/strncase.c   | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strncat.c    | 6 ++++--
 sysdeps/powerpc/powerpc64/multiarch/strncmp.c    | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strnlen.c    | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strrchr.c    | 3 ++-
 sysdeps/powerpc/powerpc64/multiarch/strspn.c     | 3 ++-
 25 files changed, 70 insertions(+), 34 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/powerpc/powerpc64/multiarch/bzero.c b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
index 660d7dc686..6275305b46 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/bzero.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/bzero.c
@@ -38,11 +38,13 @@  libc_ifunc (__bzero,
 	     && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __bzero_power10 :
 # endif
-            (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+            (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_ALTIVEC)
             ? __bzero_power8 :
 	      (hwcap & PPC_FEATURE_HAS_VSX)
 	      ? __bzero_power7 :
-		(hwcap & PPC_FEATURE_ARCH_2_05)
+		(hwcap & PPC_FEATURE_ARCH_2_05
+		 && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		? __bzero_power6 :
 		  (hwcap & PPC_FEATURE_POWER4)
 		  ? __bzero_power4
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memchr.c b/sysdeps/powerpc/powerpc64/multiarch/memchr.c
index c24186689e..f40013e061 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memchr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memchr.c
@@ -28,7 +28,8 @@  extern __typeof (__memchr) __memchr_power8 attribute_hidden;
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc (__memchr,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 	    ? __memchr_power8 :
 	    (hwcap & PPC_FEATURE_ARCH_2_06)
             ? __memchr_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcmp.c b/sysdeps/powerpc/powerpc64/multiarch/memcmp.c
index 99559bce26..89b56c103b 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memcmp.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memcmp.c
@@ -38,7 +38,8 @@  libc_ifunc_redirected (__redirect_memcmp, memcmp,
 				 && hwcap & PPC_FEATURE_HAS_VSX)
 				 ? __memcmp_power10 :
 #endif
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		       (hwcap2 & PPC_FEATURE2_ARCH_2_07
+			&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		       ? __memcmp_power8 :
 		       (hwcap & PPC_FEATURE_ARCH_2_06)
 		       ? __memcmp_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcpy.c b/sysdeps/powerpc/powerpc64/multiarch/memcpy.c
index 53ab32ef26..684ee064f2 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memcpy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memcpy.c
@@ -45,9 +45,12 @@  libc_ifunc (__libc_memcpy,
 	    (hwcap2 & PPC_FEATURE2_ARCH_3_1 && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __memcpy_power10 :
 # endif
-	    ((hwcap2 & PPC_FEATURE2_ARCH_2_07) && use_cached_memopt)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_ALTIVEC
+	     && use_cached_memopt)
 	    ? __memcpy_power8_cached :
-	      (hwcap & PPC_FEATURE_HAS_VSX)
+	      (hwcap & PPC_FEATURE_ARCH_2_06
+	       && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 	      ? __memcpy_power7 :
 		(hwcap & PPC_FEATURE_ARCH_2_06)
 		? __memcpy_a2 :
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memmove.c b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
index 637b2cbf7f..50253b4554 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memmove.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memmove.c
@@ -41,7 +41,8 @@  libc_ifunc (__libc_memmove,
 	     && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __memmove_power10 :
 #endif
-		     (hwcap & PPC_FEATURE_HAS_VSX)
+		     (hwcap & PPC_FEATURE_ARCH_2_06
+		      && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		     ? __memmove_power7
 		     : __memmove_ppc);
 
diff --git a/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c b/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
index b37e0f35b5..563095a5ec 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
@@ -33,7 +33,8 @@  extern __typeof (__mempcpy) __mempcpy_power7 attribute_hidden;
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc_redirected (__redirect___mempcpy, __mempcpy,
-		       (hwcap & PPC_FEATURE_HAS_VSX)
+		       (hwcap & PPC_FEATURE_ARCH_2_06
+			&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		       ? __mempcpy_power7
 		       : __mempcpy_ppc);
 
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memrchr.c b/sysdeps/powerpc/powerpc64/multiarch/memrchr.c
index 16bb6f0042..a8b985b06a 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memrchr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memrchr.c
@@ -28,7 +28,8 @@  extern __typeof (__memrchr) __memrchr_power8 attribute_hidden;
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc (__memrchr,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 	    ? __memrchr_power8 :
 	      (hwcap & PPC_FEATURE_ARCH_2_06)
 	      ? __memrchr_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memset.c b/sysdeps/powerpc/powerpc64/multiarch/memset.c
index 056e911699..a2bc223bcc 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memset.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memset.c
@@ -48,6 +48,7 @@  libc_ifunc (__libc_memset,
 	    ? __memset_power10 :
 # endif
             (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_ALTIVEC
 	     && GLRO(dl_cache_line_size) == 128)
             ? __memset_power8 :
 	      (hwcap & PPC_FEATURE_ARCH_2_06
diff --git a/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c b/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
index b5d2d3a635..43eb459e02 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
@@ -38,7 +38,8 @@  libc_ifunc_redirected (__redirect___rawmemchr, __rawmemchr,
 		     (hwcap2 & PPC_FEATURE2_ARCH_3_1)
 		     && (hwcap & PPC_FEATURE_HAS_VSX)
 		     ? __rawmemchr_power10 :
-		       (hwcap2 & PPC_FEATURE2_ARCH_3_00)
+		       (hwcap2 & PPC_FEATURE2_ARCH_3_00
+			&& hwcap & PPC_FEATURE_HAS_VSX)
 		       ? __rawmemchr_power9 :
 # endif
 		         (hwcap & PPC_FEATURE_ARCH_2_06)
diff --git a/sysdeps/powerpc/powerpc64/multiarch/stpcpy.c b/sysdeps/powerpc/powerpc64/multiarch/stpcpy.c
index d4eb4285fc..5be413405e 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/stpcpy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/stpcpy.c
@@ -32,12 +32,15 @@  extern __typeof (__stpcpy) __stpcpy_power9 attribute_hidden;
 
 libc_ifunc_hidden (__stpcpy, __stpcpy,
 # ifdef __LITTLE_ENDIAN__
-		   (hwcap2 & PPC_FEATURE2_ARCH_3_00)
+		   (hwcap2 & PPC_FEATURE2_ARCH_3_00
+		    && hwcap & PPC_FEATURE_HAS_VSX)
 		   ? __stpcpy_power9 :
 # endif
-		     (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		     (hwcap2 & PPC_FEATURE2_ARCH_2_07
+		      && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		     ? __stpcpy_power8
-		     : (hwcap & PPC_FEATURE_HAS_VSX)
+		     : (hwcap & PPC_FEATURE_ARCH_2_06
+		        && hwcap & PPC_FEATURE_HAS_VSX)
 		       ? __stpcpy_power7
 		       : __stpcpy_ppc);
 
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c
index 55ca6c85c4..21ce2d279b 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c
@@ -27,7 +27,8 @@  extern __typeof (__strcasecmp) __strcasecmp_power7 attribute_hidden;
 extern __typeof (__strcasecmp) __strcasecmp_power8 attribute_hidden;
 
 libc_ifunc (__libc_strcasecmp,
-	     (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	     (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	      && hwcap & PPC_FEATURE_HAS_ALTIVEC)
              ? __strcasecmp_power8:
 	     (hwcap & PPC_FEATURE_ARCH_2_06)
              ? __strcasecmp_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcasestr.c b/sysdeps/powerpc/powerpc64/multiarch/strcasestr.c
index 7e4bd3b5ac..5bb3016022 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strcasestr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcasestr.c
@@ -27,7 +27,8 @@  extern __typeof (__strcasestr) __strcasestr_power8 attribute_hidden;
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc (__strcasestr,
-		(hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		(hwcap2 & PPC_FEATURE2_ARCH_2_07
+		 && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		? __strcasestr_power8
 		: __strcasestr_ppc);
 
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcat.c b/sysdeps/powerpc/powerpc64/multiarch/strcat.c
index 6d342324c4..d8d9870824 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strcat.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcat.c
@@ -28,9 +28,11 @@  extern __typeof (strcat) __strcat_power8 attribute_hidden;
 # undef strcat
 
 libc_ifunc_redirected (__redirect_strcat, strcat,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		       (hwcap2 & PPC_FEATURE2_ARCH_2_07
+			&& hwcap & PPC_FEATURE_HAS_VSX)
 		       ? __strcat_power8
-		       : (hwcap & PPC_FEATURE_HAS_VSX)
+		       : (hwcap & PPC_FEATURE_ARCH_2_06
+			  && hwcap & PPC_FEATURE_HAS_VSX)
 			 ? __strcat_power7
 			 : __strcat_ppc);
 #endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strchr.c b/sysdeps/powerpc/powerpc64/multiarch/strchr.c
index 27c794c6b7..62b202baf9 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strchr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strchr.c
@@ -33,7 +33,8 @@  extern __typeof (strchr) __strchr_power8 attribute_hidden;
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc_redirected (__redirect_strchr, strchr,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		       (hwcap2 & PPC_FEATURE2_ARCH_2_07
+			&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		       ? __strchr_power8 :
 		       (hwcap & PPC_FEATURE_ARCH_2_06)
 		       ? __strchr_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c b/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
index 4a07b4a242..40e529b9d9 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
@@ -28,7 +28,8 @@  extern __typeof (__strchrnul) __strchrnul_power8 attribute_hidden;
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc (__strchrnul,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 	    ? __strchrnul_power8 :
 	    (hwcap & PPC_FEATURE_ARCH_2_06)
             ? __strchrnul_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcmp.c b/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
index 4b0b25fff6..8132682a99 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
@@ -35,7 +35,8 @@  extern __typeof (strcmp) __strcmp_power9 attribute_hidden;
 
 libc_ifunc_redirected (__redirect_strcmp, strcmp,
 # ifdef __LITTLE_ENDIAN__
-			(hwcap2 & PPC_FEATURE2_ARCH_3_00)
+			(hwcap2 & PPC_FEATURE2_ARCH_3_00
+			 && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 			? __strcmp_power9 :
 # endif
 		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcpy.c b/sysdeps/powerpc/powerpc64/multiarch/strcpy.c
index b733fa5a23..5af1d45cc1 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strcpy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcpy.c
@@ -32,12 +32,15 @@  extern __typeof (strcpy) __strcpy_power9 attribute_hidden;
 
 libc_ifunc_redirected (__redirect_strcpy, strcpy,
 # ifdef __LITTLE_ENDIAN__
-			(hwcap2 & PPC_FEATURE2_ARCH_3_00)
+			(hwcap2 & PPC_FEATURE2_ARCH_3_00
+			 && hwcap & PPC_FEATURE_HAS_VSX)
 			? __strcpy_power9 :
 # endif
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		       (hwcap2 & PPC_FEATURE2_ARCH_2_07
+			&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		       ? __strcpy_power8
-		       : (hwcap & PPC_FEATURE_HAS_VSX)
+		       : (hwcap & PPC_FEATURE_ARCH_2_06
+		          && hwcap & PPC_FEATURE_HAS_VSX)
 			 ? __strcpy_power7
 			 : __strcpy_ppc);
 #endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcspn.c b/sysdeps/powerpc/powerpc64/multiarch/strcspn.c
index 683aa104d7..8ba01c13b1 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strcspn.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcspn.c
@@ -27,7 +27,8 @@  extern __typeof (strcspn) __strcspn_ppc attribute_hidden;
 extern __typeof (strcspn) __strcspn_power8 attribute_hidden;
 
 libc_ifunc (__libc_strcspn,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __strcspn_power8
 	    : __strcspn_ppc);
 
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strlen.c b/sysdeps/powerpc/powerpc64/multiarch/strlen.c
index 0cd1c6faff..f1e28414e0 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strlen.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strlen.c
@@ -35,12 +35,15 @@  extern __typeof (__redirect_strlen) __strlen_power10 attribute_hidden;
 
 libc_ifunc (__libc_strlen,
 # ifdef __LITTLE_ENDIAN__
-	(hwcap2 & PPC_FEATURE2_ARCH_3_1)
+	(hwcap2 & PPC_FEATURE2_ARCH_3_1
+	 && hwcap & PPC_FEATURE_HAS_VSX)
 	? __strlen_power10 :
-	  (hwcap2 & PPC_FEATURE2_ARCH_3_00)
+	  (hwcap2 & PPC_FEATURE2_ARCH_3_00
+	   && hwcap & PPC_FEATURE_HAS_VSX)
 	  ? __strlen_power9 :
 # endif
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 	    ? __strlen_power8 :
 	      (hwcap & PPC_FEATURE_ARCH_2_06)
 	      ? __strlen_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncase.c b/sysdeps/powerpc/powerpc64/multiarch/strncase.c
index 644046bd74..2802cf2c3f 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strncase.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncase.c
@@ -27,7 +27,8 @@  extern __typeof (__strncasecmp) __strncasecmp_power7 attribute_hidden;
 extern __typeof (__strncasecmp) __strncasecmp_power8 attribute_hidden;
 
 libc_ifunc (__libc_strncasecmp,
-	     (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	     (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	      && hwcap & PPC_FEATURE_HAS_ALTIVEC)
              ? __strncasecmp_power8:
 	     (hwcap & PPC_FEATURE_ARCH_2_06)
              ? __strncasecmp_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncat.c b/sysdeps/powerpc/powerpc64/multiarch/strncat.c
index 0036fca91a..9ea294a72d 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strncat.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncat.c
@@ -26,9 +26,11 @@  extern __typeof (strncat) __strncat_power7 attribute_hidden;
 extern __typeof (strncat) __strncat_power8 attribute_hidden;
 
 libc_ifunc (strncat,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __strncat_power8
-	    : (hwcap & PPC_FEATURE_HAS_VSX)
+	    : (hwcap & PPC_FEATURE_ARCH_2_06
+	       && hwcap & PPC_FEATURE_HAS_VSX)
             ? __strncat_power7
             : __strncat_ppc);
 #endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
index 1f689e5c05..2d21122854 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
@@ -38,7 +38,8 @@  extern __typeof (strncmp) __strncmp_power9 attribute_hidden;
    ifunc symbol properly.  */
 libc_ifunc_redirected (__redirect_strncmp, strncmp,
 # ifdef __LITTLE_ENDIAN__
-			(hwcap2 & PPC_FEATURE2_ARCH_3_00)
+			(hwcap2 & PPC_FEATURE2_ARCH_3_00
+			 && hwcap & PPC_FEATURE_HAS_ALTIVEC)
 			? __strncmp_power9 :
 # endif
 		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strnlen.c b/sysdeps/powerpc/powerpc64/multiarch/strnlen.c
index baf375a75a..e68e9d9f88 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strnlen.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strnlen.c
@@ -29,7 +29,8 @@  extern __typeof (__strnlen) __strnlen_power8 attribute_hidden;
 # undef strnlen
 # undef __strnlen
 libc_ifunc_redirected (__redirect___strnlen, __strnlen,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		       (hwcap2 & PPC_FEATURE2_ARCH_2_07
+			&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		       ? __strnlen_power8 :
 			 (hwcap & PPC_FEATURE_ARCH_2_06)
 			 ? __strnlen_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strrchr.c b/sysdeps/powerpc/powerpc64/multiarch/strrchr.c
index 1c9eea1817..7f0cf2a1b7 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strrchr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strrchr.c
@@ -31,7 +31,8 @@  extern __typeof (strrchr) __strrchr_power8 attribute_hidden;
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc_redirected (__redirect_strrchr, strrchr,
-		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+		       (hwcap2 & PPC_FEATURE2_ARCH_2_07
+			&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
 		       ? __strrchr_power8 :
 		       (hwcap & PPC_FEATURE_ARCH_2_06)
 		       ? __strrchr_power7
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strspn.c b/sysdeps/powerpc/powerpc64/multiarch/strspn.c
index 70167a176b..7613ab3d55 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/strspn.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/strspn.c
@@ -27,7 +27,8 @@  extern __typeof (strspn) __strspn_ppc attribute_hidden;
 extern __typeof (strspn) __strspn_power8 attribute_hidden;
 
 libc_ifunc (__libc_strspn,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07
+	     && hwcap & PPC_FEATURE_HAS_VSX)
 	    ? __strspn_power8
 	    : __strspn_ppc);