public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* [PATCH roland/arm-strlen] Make armv6t2 strlen work in ARM mode too.
@ 2013-08-30 18:06 Roland McGrath
  2013-08-30 20:36 ` Joseph S. Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Roland McGrath @ 2013-08-30 18:06 UTC (permalink / raw)
  To: libc-ports

I tested that this has no effect (assembled code wholly unchanged) on
arm-linux-gnueabihf.  I tested that the ARM-mode support actually works by
hacking in "#define NO_THUMB" at the top and verifying no failures from
'make check subdirs=string'.

Incidentally, assembly writers really ought to write more comments!  For
example, I deduced the only plausible reason for using an explicit bne.w
and added a comment about it, but it is exactly the sort of non-obvious
subtle microoptimization that desperately needed clear comments in the
first place.


OK for trunk?


Thanks,
Roland


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

	* sysdeps/arm/armv6t2/strlen.S: Include <arm-features.h> first thing.
	[NO_THUMB]: Adapt code for ARM mode.

--- a/ports/sysdeps/arm/armv6t2/strlen.S
+++ b/ports/sysdeps/arm/armv6t2/strlen.S
@@ -21,6 +21,7 @@
 
  */
 
+#include <arm-features.h>               /* This might #define NO_THUMB.  */
 #include <sysdep.h>
 
 #ifdef __ARMEB__
@@ -31,9 +32,24 @@
 #define S2HI		lsl
 #endif
 
-	/* This code requires Thumb.  */
+#ifndef NO_THUMB
+/* This code is best on Thumb.  */
 	.thumb
-	.syntax unified
+#else
+/* Using bne.w explicitly is desirable in Thumb mode because it helps
+   align the following label without a nop.  In ARM mode there is no
+   such difference.  */
+.macro bne.w label
+	bne \label
+.endm
+
+/* This clobbers the condition codes, which the real Thumb cbnz instruction
+   does not do.  But it doesn't matter for any of the uses here.  */
+.macro cbnz reg, label
+	cmp \reg, #0
+	bne \label
+.endm
+#endif
 
 /* Parameters and result.  */
 #define srcin		r0
@@ -130,9 +146,16 @@ ENTRY(strlen)
 	tst	tmp1, #4
 	pld	[src, #64]
 	S2HI	tmp2, const_m1, tmp2
+#ifdef NO_THUMB
+	mvn	tmp1, tmp2
+	orr	data1a, data1a, tmp1
+	itt	ne
+	orrne	data1b, data1b, tmp1
+#else
 	orn	data1a, data1a, tmp2
 	itt	ne
 	ornne	data1b, data1b, tmp2
+#endif
 	movne	data1a, const_m1
 	mov	const_0, #0
 	b	.Lstart_realigned

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

* Re: [PATCH roland/arm-strlen] Make armv6t2 strlen work in ARM mode too.
  2013-08-30 18:06 [PATCH roland/arm-strlen] Make armv6t2 strlen work in ARM mode too Roland McGrath
@ 2013-08-30 20:36 ` Joseph S. Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2013-08-30 20:36 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-ports

On Fri, 30 Aug 2013, Roland McGrath wrote:

> I tested that this has no effect (assembled code wholly unchanged) on
> arm-linux-gnueabihf.  I tested that the ARM-mode support actually works by
> hacking in "#define NO_THUMB" at the top and verifying no failures from
> 'make check subdirs=string'.
> 
> Incidentally, assembly writers really ought to write more comments!  For
> example, I deduced the only plausible reason for using an explicit bne.w
> and added a comment about it, but it is exactly the sort of non-obvious
> subtle microoptimization that desperately needed clear comments in the
> first place.
> 
> 
> OK for trunk?

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

end of thread, other threads:[~2013-08-30 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-30 18:06 [PATCH roland/arm-strlen] Make armv6t2 strlen work in ARM mode too Roland McGrath
2013-08-30 20:36 ` Joseph S. Myers

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