public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use   NEON when compiler does
@ 2013-05-13 22:47 Roland McGrath
  2013-05-13 23:12 ` Joseph S. Myers
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Roland McGrath @ 2013-05-13 22:47 UTC (permalink / raw)
  To: libc-ports

When the compiler is emitting NEON instructions anyway, there is no point
in using IFUNC when we can just use the NEON memcpy unconditionally.

Tested on armv7l-linux-gnueabihf with CC='gcc -mfpu=neon',
no check-abi failures, no regressions in 'make check subdirs=string'.


Thanks,
Roland


ports/ChangeLog.arm
2013-05-13  Roland McGrath  <roland@hack.frob.com>

	* sysdeps/arm/armv7/multiarch/memcpy.S [__ARM_NEON__]: Don't define
	memcpy here, just __memcpy_arm and __aeabi_memcpy*.
	* sysdeps/arm/armv7/multiarch/memcpy_neon.S [__ARM_NEON__]:
	Define memcpy here, not __memcpy_neon.
	* sysdeps/arm/armv7/multiarch/memcpy_vfp.S [__ARM_NEON__]:
	Define nothing here.
	* sysdeps/arm/armv7/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list) [__ARM_NEON__]: Don't list __memcpy_vfp;
	use memcpy name for NEON implementation.

--- a/ports/sysdeps/arm/armv7/multiarch/ifunc-impl-list.c
+++ b/ports/sysdeps/arm/armv7/multiarch/ifunc-impl-list.c
@@ -35,9 +35,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
   IFUNC_IMPL (i, name, memcpy,
 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_ARM_NEON,
-			      __memcpy_neon)
+#ifdef __ARM_NEON__
+                              memcpy
+#else
+			      __memcpy_neon
+#endif
+                              )
+#ifndef __ARM_NEON__
 	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_ARM_VFP,
 			      __memcpy_vfp)
+#endif
 	      IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_arm));
 
   return i;
--- a/ports/sysdeps/arm/armv7/multiarch/memcpy.S
+++ b/ports/sysdeps/arm/armv7/multiarch/memcpy.S
@@ -22,27 +22,29 @@
 #include <sysdep.h>
 #include <rtld-global-offsets.h>
 
-#if !defined NOT_IN_libc
+#ifndef NOT_IN_libc
+/* Under __ARM_NEON__, memcpy_neon.S defines the name memcpy.  */
+# ifndef __ARM_NEON__
 	.text
 ENTRY(memcpy)
 	.type	memcpy, %gnu_indirect_function
-#ifdef __SOFTFP__
+# ifdef __SOFTFP__
 	ldr	r1, .Lmemcpy_arm
 	tst	r0, #HWCAP_ARM_VFP
 	ldrne	r1, .Lmemcpy_vfp
-#else
+# else
 	ldr	r1, .Lmemcpy_vfp
-#endif
+# endif
 	tst	r0, #HWCAP_ARM_NEON
 	ldrne	r1, .Lmemcpy_neon
 1:
 	add	r0, r1, pc
 	DO_RET(lr)
 
-#ifdef __SOFTFP__
+# ifdef __SOFTFP__
 .Lmemcpy_arm:
 	.long	C_SYMBOL_NAME(__memcpy_arm) - 1b - PC_OFS
-#endif
+# endif
 .Lmemcpy_neon:
 	.long	C_SYMBOL_NAME(__memcpy_neon) - 1b - PC_OFS
 .Lmemcpy_vfp:
@@ -51,6 +53,7 @@ ENTRY(memcpy)
 END(memcpy)
 
 libc_hidden_builtin_def (memcpy)
+#endif  /* Not __ARM_NEON__.  */
 
 /* These versions of memcpy are defined not to clobber any VFP or NEON
    registers so they must always call the ARM variant of the memcpy code.  */
--- a/ports/sysdeps/arm/armv7/multiarch/memcpy_neon.S
+++ b/ports/sysdeps/arm/armv7/multiarch/memcpy_neon.S
@@ -1,3 +1,9 @@
+#ifdef __ARM_NEON__
+/* Under __ARM_NEON__, this file defines memcpy directly.  */
+libc_hidden_builtin_def (memcpy)
+#else
+# define memcpy __memcpy_neon
+#endif
+
 #define MEMCPY_NEON
-#define memcpy __memcpy_neon
 #include "memcpy_impl.S"
--- a/ports/sysdeps/arm/armv7/multiarch/memcpy_vfp.S
+++ b/ports/sysdeps/arm/armv7/multiarch/memcpy_vfp.S
@@ -1,3 +1,7 @@
-#define MEMCPY_VFP
-#define memcpy __memcpy_vfp
-#include "memcpy_impl.S"
+/* Under __ARM_NEON__, memcpy_neon.S defines memcpy directly
+   and the __memcpy_vfp code will never be used.  */
+#ifndef __ARM_NEON__
+# define MEMCPY_VFP
+# define memcpy __memcpy_vfp
+# include "memcpy_impl.S"
+#endif

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

* Re: [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use   NEON when compiler does
  2013-05-13 22:47 [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use NEON when compiler does Roland McGrath
@ 2013-05-13 23:12 ` Joseph S. Myers
  2013-05-14  7:47 ` Andreas Schwab
  2013-05-14 15:47 ` Richard Henderson
  2 siblings, 0 replies; 6+ messages in thread
From: Joseph S. Myers @ 2013-05-13 23:12 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-ports

On Mon, 13 May 2013, Roland McGrath wrote:

> When the compiler is emitting NEON instructions anyway, there is no point
> in using IFUNC when we can just use the NEON memcpy unconditionally.
> 
> Tested on armv7l-linux-gnueabihf with CC='gcc -mfpu=neon',
> no check-abi failures, no regressions in 'make check subdirs=string'.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use   NEON when compiler does
  2013-05-13 22:47 [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use NEON when compiler does Roland McGrath
  2013-05-13 23:12 ` Joseph S. Myers
@ 2013-05-14  7:47 ` Andreas Schwab
  2013-05-17  0:31   ` Roland McGrath
  2013-05-14 15:47 ` Richard Henderson
  2 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2013-05-14  7:47 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-ports

Roland McGrath <roland@hack.frob.com> writes:

>    IFUNC_IMPL (i, name, memcpy,
>  	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_ARM_NEON,
> -			      __memcpy_neon)
> +#ifdef __ARM_NEON__
> +                              memcpy
> +#else
> +			      __memcpy_neon
> +#endif
> +                              )

Preprocessor directives in macro arguments give undefined behaviour.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use   NEON when compiler does
  2013-05-13 22:47 [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use NEON when compiler does Roland McGrath
  2013-05-13 23:12 ` Joseph S. Myers
  2013-05-14  7:47 ` Andreas Schwab
@ 2013-05-14 15:47 ` Richard Henderson
  2013-05-17  0:32   ` Roland McGrath
  2 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2013-05-14 15:47 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-ports

On 05/13/2013 03:47 PM, Roland McGrath wrote:
>    IFUNC_IMPL (i, name, memcpy,
>  	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_ARM_NEON,
> -			      __memcpy_neon)
> +#ifdef __ARM_NEON__
> +                              memcpy
> +#else
> +			      __memcpy_neon
> +#endif
> +                              )
> +#ifndef __ARM_NEON__
>  	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_ARM_VFP,
>  			      __memcpy_vfp)
> +#endif
>  	      IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_arm));

I think you're better off leaving the __memcpy_neon symbol in all cases.
Having memcpy be an alias to __memcpy_neon would make the rest of the patch
simpler.


r~

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

* Re: [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use   NEON when compiler does
  2013-05-14  7:47 ` Andreas Schwab
@ 2013-05-17  0:31   ` Roland McGrath
  0 siblings, 0 replies; 6+ messages in thread
From: Roland McGrath @ 2013-05-17  0:31 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-ports

> Preprocessor directives in macro arguments give undefined behaviour.

We write in GNU C, where they have always been perfectly fine.

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

* Re: [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use   NEON when compiler does
  2013-05-14 15:47 ` Richard Henderson
@ 2013-05-17  0:32   ` Roland McGrath
  0 siblings, 0 replies; 6+ messages in thread
From: Roland McGrath @ 2013-05-17  0:32 UTC (permalink / raw)
  To: Richard Henderson; +Cc: libc-ports

> I think you're better off leaving the __memcpy_neon symbol in all cases.
> Having memcpy be an alias to __memcpy_neon would make the rest of the patch
> simpler.

I don't see what could be any simpler (or different) other than this one
#ifdef in the test case.

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

end of thread, other threads:[~2013-05-17  0:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-13 22:47 [PATCH roland/arm-memcpy] ARM: Make multiarch memcpy always use NEON when compiler does Roland McGrath
2013-05-13 23:12 ` Joseph S. Myers
2013-05-14  7:47 ` Andreas Schwab
2013-05-17  0:31   ` Roland McGrath
2013-05-14 15:47 ` Richard Henderson
2013-05-17  0:32   ` Roland McGrath

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