[PATCH] MIPS: UAPI: Disable __arch_swab{16,32} when using MIPS16

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some GCC versions (e.g. 4.8.3) can incorrectly inline a function with
MIPS32 instructions into another function with MIPS16 code [1], causing
the assembler to genereate incorrect binary code or fail right away
complaining about unrecognized opcode.

In the case of __arch_swab{16,32}, when inlined by the compiler with
flags `-mips32r2 -mips16 -Os', the assembler can fail with the following
error.

    {standard input}:79: Error: unrecognized opcode `wsbh $2,$2'

For performance concerns and to workaround the issue already existing in
older compilers, just ignore these 2 functions when compiling with
mips16 enabled.

 [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55777

Signed-off-by: Yousong Zhou <yszhou4tech@xxxxxxxxx>
---
 arch/mips/include/uapi/asm/swab.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/mips/include/uapi/asm/swab.h b/arch/mips/include/uapi/asm/swab.h
index 8f2d184..8396d5a 100644
--- a/arch/mips/include/uapi/asm/swab.h
+++ b/arch/mips/include/uapi/asm/swab.h
@@ -16,6 +16,10 @@
 #if (defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) ||		\
     defined(_MIPS_ARCH_LOONGSON3A)
 
+/*
+ * Enable the optimized version only when compiling without MIPS16.
+ */
+#ifndef __mips16
 static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
 {
 	__asm__(
@@ -44,6 +48,7 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
 	return x;
 }
 #define __arch_swab32 __arch_swab32
+#endif /* ifndef __mips16 */
 
 /*
  * Having already checked for MIPS R2, enable the optimized version for
-- 
1.7.10.4





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux