From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Wed, 06 Oct 2010 07:51:30 +0200 Subject: [U-Boot] [PATCH] orion5x: optimize window size computation In-Reply-To: <4CAB9B40.7090008@free.fr> References: <1286230940-26976-1-git-send-email-albert.aribaud@free.fr> <4CAB9B40.7090008@free.fr> Message-ID: <4CAC0E62.8030101@free.fr> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Le 05/10/2010 23:40, Chris Moore a ?crit : > Hi Prafulla, > > Le 05/10/2010 07:57, Prafulla Wadaskar a ?crit : >> >> >>> -----Original Message----- >>> From: u-boot-bounces at lists.denx.de >>> [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert Aribaud >>> Sent: Tuesday, October 05, 2010 3:52 AM >>> To: u-boot at lists.denx.de >>> Subject: [U-Boot] [PATCH] orion5x: optimize window size computation >>> >>> >>> Signed-off-by: Chris Moore >>> --- >>> >>> This is a simple optimization of the orion5x window size >>> computation. This code was contributed by Chris Moore so >>> I put his Signed-off-by rather than mine. >> This is wrong, you should be singed-off since you are posting and >> Chris can be contributor >> Or let him post the patch. > > I asked Albert to post the patch as I am mainly a U-Boot lurker and I > have no U-Boot git tree. > If there is a problem I don't mind if he signs off either with or > without me. Or how about a double Signed-off-by? >> BTW: How much this saves on size? More than 53% of the code size! That's 28 bytes instead of 60. :) > It is not so much a question of size. I am afraid that the other version > was just plain *wrong* :( Indeed. Prafulla, you'll remember that there was a generally horribly wrong version before, which I'd fixed with what I thought was a correct version, and is for many sizes, principally those of the for 2**N, but not all. Chris' version fixes all cases. > The loop version may be slightly shorter in code size, particularly if > one removes the unnecessary and with 0x0000ffff at the end. It's not: yours is shorter, thanks to the compiler being able to optimize things. > But aesthetically I find the version above much more pleasing. > (Didn't Donald Knuth write "The *Art* of Computer Programming"?) > It is also much faster for large window sizes but this probably doesn't > matter here. Your code is 7 instructions flat whatever the size, whereas the loop has a fixed 9 instruction setup and exit penalty, plus 5 instructions per bit shift (plus one literal). So your code is *always* faster. > Cheers, > Chris Amicalement, -- Albert.