Patchwork [2/4] arm: Fix armv7 neon strcmp on ARM mode

mail settings
Submitter Adhemerval Zanella Netto
Date April 11, 2018, 9:16 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/26688/
State New
Headers show


Adhemerval Zanella Netto - April 11, 2018, 9:16 p.m.
Current optimized armv7 neon strcmp 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 'prepare_mask' does
not build (it sets the 'mvn' instruction to use register predicate in
shift amount).  This patch fixes it by using a S2HI plus mvn to mimic
the expected nor operation.

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

	[BZ #23031]
	* sysdeps/arm/armv7/strcmp.S [!__thumb__] (prepare_mask): Fix build
	and logic.
 ChangeLog                  | 4 ++++
 sysdeps/arm/armv7/strcmp.S | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)


diff --git a/sysdeps/arm/armv7/strcmp.S b/sysdeps/arm/armv7/strcmp.S
index 060b865..a20b3e5 100644
--- a/sysdeps/arm/armv7/strcmp.S
+++ b/sysdeps/arm/armv7/strcmp.S
@@ -82,8 +82,7 @@ 
 #define data2		r3
 #define syndrome	tmp2
-#ifndef NO_THUMB
+#ifdef __thumb__
 /* This code is best on Thumb.  */
@@ -97,7 +96,8 @@ 
 /* In ARM code we don't have ORN, but we can use MVN with a register shift.  */
 .macro prepare_mask mask_reg, nbits_reg
-	mvn \mask_reg, const_m1, S2HI \nbits_reg
+	S2HI \mask_reg, const_m1, \nbits_reg
+	mvn \mask_reg, \mask_reg
 .macro apply_mask data_reg, mask_reg
 	orr \data_reg, \data_reg, \mask_reg