From patchwork Fri Sep 9 12:10:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 114091 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 72097B74B8 for ; Fri, 9 Sep 2011 22:11:14 +1000 (EST) Received: by ozlabs.org (Postfix) id 75AB0B6FA3; Fri, 9 Sep 2011 22:11:06 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from gw1.transmode.se (gw1.transmode.se [195.58.98.146]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 157F6B6FA6 for ; Fri, 9 Sep 2011 22:11:05 +1000 (EST) Received: from mail1.transmode.se (mail1.transmode.se [192.168.201.18]) by gw1.transmode.se (Postfix) with ESMTP id D22A8258283 for ; Fri, 9 Sep 2011 14:11:00 +0200 (CEST) Received: from gentoo-jocke.transmode.se ([172.20.4.10]) by mail1.transmode.se (Lotus Domino Release 8.5.2FP3) with ESMTP id 2011090914110040-114609 ; Fri, 9 Sep 2011 14:11:00 +0200 Received: from gentoo-jocke.transmode.se (localhost [127.0.0.1]) by gentoo-jocke.transmode.se (8.14.4/8.14.0) with ESMTP id p89CB0L6012313; Fri, 9 Sep 2011 14:11:00 +0200 Received: (from jocke@localhost) by gentoo-jocke.transmode.se (8.14.4/8.14.4/Submit) id p89CB0dk012312; Fri, 9 Sep 2011 14:11:00 +0200 From: Joakim Tjernlund To: linuxppc-dev@ozlabs.org Subject: [PATCH] powerpc: Optimize __arch_swab32 and __arch_swab16 Date: Fri, 9 Sep 2011 14:10:58 +0200 Message-Id: <1315570258-12275-1-git-send-email-Joakim.Tjernlund@transmode.se> X-Mailer: git-send-email 1.7.3.4 X-MIMETrack: Itemize by SMTP Server on mail1/Transmode(Release 8.5.2FP3|July 10, 2011) at 09/09/2011 14:11:00, Serialize by Router on mail1/Transmode(Release 8.5.2FP3|July 10, 2011) at 09/09/2011 14:11:00, Serialize complete at 09/09/2011 14:11:00 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org PPC __arch_swab32 and __arch_swab16 generates non optimal code. They do not schedule very well, need to copy its input register and swab16 needs an extra insn to clear its upper bits. Fix this with better inline ASM. Signed-off-by: Joakim Tjernlund --- arch/powerpc/include/asm/swab.h | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm/swab.h b/arch/powerpc/include/asm/swab.h index c581e3e..3b9a200 100644 --- a/arch/powerpc/include/asm/swab.h +++ b/arch/powerpc/include/asm/swab.h @@ -61,25 +61,25 @@ static inline void __arch_swab32s(__u32 *addr) static inline __attribute_const__ __u16 __arch_swab16(__u16 value) { - __u16 result; - - __asm__("rlwimi %0,%1,8,16,23" - : "=r" (result) - : "r" (value), "0" (value >> 8)); - return result; + __asm__("rlwimi %0,%0,16,0x00ff0000\n\t" + "rlwinm %0,%0,24,0x0000ffff" + : "+r"(value)); + return value; } #define __arch_swab16 __arch_swab16 static inline __attribute_const__ __u32 __arch_swab32(__u32 value) { - __u32 result; - - __asm__("rlwimi %0,%1,24,16,23\n\t" - "rlwimi %0,%1,8,8,15\n\t" - "rlwimi %0,%1,24,0,7" - : "=r" (result) - : "r" (value), "0" (value >> 24)); - return result; + __u32 tmp; + + __asm__("rlwimi %0,%1,24,0xffffffff" + : "=r" (value) : "r" (value)); + tmp = value; + __asm__("rlwimi %0,%1,16,0x00ff0000" + : "+r" (value) : "r" (tmp)); + __asm__("rlwimi %0,%1,16,0x000000ff" + : "+r" (value) : "r" (tmp)); + return value; } #define __arch_swab32 __arch_swab32