public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] arm: Fix armv7 neon memchr on ARM mode
@ 2018-04-11 21:16 Adhemerval Zanella
  2018-04-11 21:16 ` [PATCH 4/4] arm: Enable ARM mode for armv6 strlen Adhemerval Zanella
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2018-04-11 21:16 UTC (permalink / raw)
  To: libc-alpha

Current optimized armv7 neon memchr uses the NO_THUMB wrongly to
conditionalize thumb instruction usage.  The flags is meant to be
defined before sysdep.h inclusion and to indicate the assembly
requires to build in ARM mode, not to check whether thumb is
enable or not.  This patch fixes it by using the GCC provided
'__thumb__' instead.

Also, even if the implementation is fixed to not use thumb instructions
it was clearly not proper checked in ARM mode: the carry bit flag will
be reset in previous 'cmp synd, #0' and thus the 'bhi cntin, #0' won't
be able to branch correctly if the loop finishes with 'cntin' being
negative (indicating that some bytes still require to be checked).
This patch also fixes it by checking the carry flag in previous loop
iteration directly (in ARM mode it will run both '.Lmasklast' and
'.Ltail' even if no byte is found in last loop iteration).

Checked on arm-linux-gnueabihf (with -marm and -mthumb mode).

	[BZ #23031]
	* sysdeps/arm/armv7/multiarch/memchr_neon.S (memchr): Fix tail check
	on ARM mode.
	(NO_THUMB): Check __thumb__ instead.
---
 ChangeLog                                 | 7 +++++++
 sysdeps/arm/armv7/multiarch/memchr_neon.S | 9 +++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/sysdeps/arm/armv7/multiarch/memchr_neon.S b/sysdeps/arm/armv7/multiarch/memchr_neon.S
index 1b2ae75..1b2a69d 100644
--- a/sysdeps/arm/armv7/multiarch/memchr_neon.S
+++ b/sysdeps/arm/armv7/multiarch/memchr_neon.S
@@ -68,7 +68,7 @@
  * allows to identify exactly which byte has matched.
  */
 
-#ifndef NO_THUMB
+#ifdef __thumb__
 	.thumb_func
 #else
 	.arm
@@ -132,7 +132,7 @@ ENTRY(memchr)
 	/* The first block can also be the last */
 	bls		.Lmasklast
 	/* Have we found something already? */
-#ifndef NO_THUMB
+#ifdef __thumb__
 	cbnz		synd, .Ltail
 #else
 	cmp		synd, #0
@@ -176,14 +176,11 @@ ENTRY(memchr)
 	vpadd.i8	vdata0_0, vdata0_0, vdata1_0
 	vpadd.i8	vdata0_0, vdata0_0, vdata0_0
 	vmov		synd, vdata0_0[0]
-#ifndef NO_THUMB
+#ifdef __thumb__
 	cbz		synd, .Lnotfound
 	bhi		.Ltail	/* Uses the condition code from
 				   subs cntin, cntin, #32 above.  */
 #else
-	cmp		synd, #0
-	beq		.Lnotfound
-	cmp		cntin, #0
 	bhi		.Ltail
 #endif
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: [PATCH 4/4] arm: Enable ARM mode for armv6 strlen
@ 2018-04-13 15:10 Wilco Dijkstra
  2018-04-13 15:43 ` Wilco Dijkstra
  0 siblings, 1 reply; 26+ messages in thread
From: Wilco Dijkstra @ 2018-04-13 15:10 UTC (permalink / raw)
  To: adhemerval.zanella; +Cc: pb, Ramana Radhakrishnan, nd, libc-alpha

Hi,

I can't see a valid reason for disabling Thumb-2 when it is available - it's not slower
and if necessary you can align loops or force Thumb-2 instructions to be 32 bit in an inner
loop. So basically if you have Thumb-2 available you might as well use it to get smaller
code - there is no advantage in using Arm. Supporting a no-Thumb-2 build would be
additional maintenance (unless it was an official variant it would not be tested as you've
shown, and I think there are already too many variants...).

Also keeping assembly code clean without lots of #if's that make it hard to follow the
logic (or the carry flags!) is best.

Wilco

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

end of thread, other threads:[~2018-04-16 14:16 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11 21:16 [PATCH 1/4] arm: Fix armv7 neon memchr on ARM mode Adhemerval Zanella
2018-04-11 21:16 ` [PATCH 4/4] arm: Enable ARM mode for armv6 strlen Adhemerval Zanella
2018-04-11 22:12   ` Phil Blundell
2018-04-12 12:42     ` Adhemerval Zanella
2018-04-12 15:33       ` Phil Blundell
2018-04-12 16:16         ` Adhemerval Zanella
2018-04-12 19:20           ` Adhemerval Zanella
2018-04-12 19:28             ` Phil Blundell
     [not found]               ` <CAJA7tRahZ7L=zBs2z+zgCR=RTuccipdjBXhprjxybErebUwv1A@mail.gmail.com>
2018-04-12 19:41                 ` Adhemerval Zanella
2018-04-12 20:31                   ` Phil Blundell
2018-04-12 20:49                     ` Adhemerval Zanella
2018-04-13  9:56                       ` Phil Blundell
2018-04-13 11:56                         ` Adhemerval Zanella
2018-04-13 12:06                         ` Ramana Radhakrishnan
2018-04-13 12:44                           ` Phil Blundell
2018-04-13 14:40                             ` Adhemerval Zanella
2018-04-13 15:07                               ` Phil Blundell
2018-04-13 16:42                                 ` Adhemerval Zanella
2018-04-13 19:09                                   ` Phil Blundell
2018-04-13 20:12                                     ` Adhemerval Zanella
2018-04-16 14:16                                     ` Richard Earnshaw (lists)
2018-04-11 21:16 ` [PATCH 3/4] arm: Enable ARM mode for armv6 memchr Adhemerval Zanella
2018-04-11 21:16 ` [PATCH 2/4] arm: Fix armv7 neon strcmp on ARM mode Adhemerval Zanella
2018-04-13 15:10 [PATCH 4/4] arm: Enable ARM mode for armv6 strlen Wilco Dijkstra
2018-04-13 15:43 ` Wilco Dijkstra
2018-04-13 15:48   ` Florian Weimer

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