From mboxrd@z Thu Jan 1 00:00:00 1970 From: Russell King Date: Thu, 26 Jan 2006 08:55:41 +0000 Subject: Re: [PATCH 3/6] C-language equivalents of include/asm-*/bitops.h Message-Id: <20060126085540.GA15377@flint.arm.linux.org.uk> List-Id: References: <20060125112625.GA18584@miraclelinux.com> <20060125113206.GD18584@miraclelinux.com> <20060125200250.GA26443@flint.arm.linux.org.uk> <20060126000618.GA5592@twiddle.net> In-Reply-To: <20060126000618.GA5592@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Akinobu Mita , linux-kernel@vger.kernel.org, Ivan Kokshaysky , Ian Molton , dev-etrax@axis.com, David Howells , Yoshinori Sato , Linus Torvalds , linux-ia64@vger.kernel.org, Hirokazu Takata , linux-m68k@vger.kernel.org, Greg Ungerer , linux-mips@linux-mips.org, parisc-linux@parisc-linux.org, linuxppc-dev@ozlabs.org, linux390@de.ibm.com, linuxsh-dev@lists.sourceforge.net, linuxsh-shmedia-dev@lists.sourceforge.net, sparclinux@vger.kernel.org, ultralinux@vger.kernel.org, Miles Bader , Andi Kleen , Chris Zankel On Wed, Jan 25, 2006 at 04:06:18PM -0800, Richard Henderson wrote: > On Wed, Jan 25, 2006 at 08:02:50PM +0000, Russell King wrote: > > > + s = 16; if (word << 16 != 0) s = 0; b += s; word >>= s; > > > + s = 8; if (word << 24 != 0) s = 0; b += s; word >>= s; > > > + s = 4; if (word << 28 != 0) s = 0; b += s; word >>= s; > ... > > Basically, shifts which depend on a variable are more expensive than > > constant-based shifts. > > Actually, they're all constant shifts. Just written stupidly. Unfortunately that's not correct. You do not appear to have checked the compiler output like I did - this code does _not_ generate constant shifts. -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 26 Jan 2006 08:51:58 +0000 (GMT) Received: from caramon.arm.linux.org.uk ([212.18.232.186]:46863 "EHLO caramon.arm.linux.org.uk") by ftp.linux-mips.org with ESMTP id S8133397AbWAZIvj (ORCPT ); Thu, 26 Jan 2006 08:51:39 +0000 Received: from flint.arm.linux.org.uk ([2002:d412:e8ba:1:201:2ff:fe14:8fad]) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:DES-CBC3-SHA:168) (Exim 4.52) id 1F22ux-0002Qt-9e; Thu, 26 Jan 2006 08:55:47 +0000 Received: from rmk by flint.arm.linux.org.uk with local (Exim 4.52) id 1F22ur-00045B-EI; Thu, 26 Jan 2006 08:55:41 +0000 Date: Thu, 26 Jan 2006 08:55:41 +0000 From: Russell King To: Akinobu Mita , linux-kernel@vger.kernel.org, Ivan Kokshaysky , Ian Molton , dev-etrax@axis.com, David Howells , Yoshinori Sato , Linus Torvalds , linux-ia64@vger.kernel.org, Hirokazu Takata , linux-m68k@lists.linux-m68k.org, Greg Ungerer , linux-mips@linux-mips.org, parisc-linux@parisc-linux.org, linuxppc-dev@ozlabs.org, linux390@de.ibm.com, linuxsh-dev@lists.sourceforge.net, linuxsh-shmedia-dev@lists.sourceforge.net, sparclinux@vger.kernel.org, ultralinux@vger.kernel.org, Miles Bader , Andi Kleen , Chris Zankel Subject: Re: [PATCH 3/6] C-language equivalents of include/asm-*/bitops.h Message-ID: <20060126085540.GA15377@flint.arm.linux.org.uk> Mail-Followup-To: Akinobu Mita , linux-kernel@vger.kernel.org, Ivan Kokshaysky , Ian Molton , dev-etrax@axis.com, David Howells , Yoshinori Sato , Linus Torvalds , linux-ia64@vger.kernel.org, Hirokazu Takata , linux-m68k@lists.linux-m68k.org, Greg Ungerer , linux-mips@linux-mips.org, parisc-linux@parisc-linux.org, linuxppc-dev@ozlabs.org, linux390@de.ibm.com, linuxsh-dev@lists.sourceforge.net, linuxsh-shmedia-dev@lists.sourceforge.net, sparclinux@vger.kernel.org, ultralinux@vger.kernel.org, Miles Bader , Andi Kleen , Chris Zankel References: <20060125112625.GA18584@miraclelinux.com> <20060125113206.GD18584@miraclelinux.com> <20060125200250.GA26443@flint.arm.linux.org.uk> <20060126000618.GA5592@twiddle.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060126000618.GA5592@twiddle.net> User-Agent: Mutt/1.4.1i Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 10168 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: rmk+lkml@arm.linux.org.uk Precedence: bulk X-list: linux-mips On Wed, Jan 25, 2006 at 04:06:18PM -0800, Richard Henderson wrote: > On Wed, Jan 25, 2006 at 08:02:50PM +0000, Russell King wrote: > > > + s = 16; if (word << 16 != 0) s = 0; b += s; word >>= s; > > > + s = 8; if (word << 24 != 0) s = 0; b += s; word >>= s; > > > + s = 4; if (word << 28 != 0) s = 0; b += s; word >>= s; > ... > > Basically, shifts which depend on a variable are more expensive than > > constant-based shifts. > > Actually, they're all constant shifts. Just written stupidly. Unfortunately that's not correct. You do not appear to have checked the compiler output like I did - this code does _not_ generate constant shifts. -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core