Re: * 4 converted to << 2 for networking code

2001-01-10 Thread H. Peter Anvin
Followup to: <[EMAIL PROTECTED]> By author:=?iso-8859-1?Q?Jakob_=D8stergaard?= <[EMAIL PROTECTED]> In newsgroup: linux.dev.kernel > > On most processors <<2 is slower than *4. > That's a funny statement. Which processors do you include in "most"? That has not been my experience. > It's o

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread Matthias Andree
On Wed, 10 Jan 2001, antirez wrote: > Hi all, > > The attached patch converts many occurences of '* 4' in the networking code > (often used to convert in bytes the TCP data offset and the IP header len) > to the faster '<< 2'. Since this was a quite repetitive work it's better > if someone doubl

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread Pauline Middelink
On Wed, 10 Jan 2001 around 18:25:46 +0100, antirez wrote: > On Wed, Jan 10, 2001 at 04:11:46PM +0100, Jakob ?stergaard wrote: > > On most processors <<2 is slower than *4. It's outright stupid to > > write <<2 when we mean *4 in order to optimize for one out of a > > gazillion supported archite

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread Jamie Lokier
Mike Harrold wrote: > Be careful. *4 is not a simple <<2 substitution (by the compiler) if > the variable is signed. *4 translates to 3 instructions (on x86) if > it's an int. I think you mean /4 is not the same as >>2 if the variable is signed. In general, non-widening multiplies give the same

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread Chris Jones
Mike Harrold <[EMAIL PROTECTED]> writes: [...] My feeling is that it shouldn't matter if you use <<2 or *4 even if the compiler optimises - one would hope that the compiler would optimise to the fastest in both directions. I agree this should be left to the compiler. The programmer shoul

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread antirez
On Wed, Jan 10, 2001 at 04:11:46PM +0100, Jakob ?stergaard wrote: > On most processors <<2 is slower than *4. It's outright stupid to > write <<2 when we mean *4 in order to optimize for one out of a > gazillion supported architectures - even more so when the compiler > for the one CPU where <<

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread Mike Harrold
> > On Wed, Jan 10, 2001 at 06:03:22PM +0100, antirez wrote: > > On Wed, Jan 10, 2001 at 09:54:04AM -0500, Brian Gerst wrote: > > > This patch isn't really necessary, because GCC will automatically > > > convert multiplications and divisions by powers of two to use shifts. > > > > Sure, but sinc

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread Jakob Østergaard
On Wed, Jan 10, 2001 at 06:03:22PM +0100, antirez wrote: > On Wed, Jan 10, 2001 at 09:54:04AM -0500, Brian Gerst wrote: > > This patch isn't really necessary, because GCC will automatically > > convert multiplications and divisions by powers of two to use shifts. > > Sure, but since many << 2 alr

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread antirez
On Wed, Jan 10, 2001 at 09:54:04AM -0500, Brian Gerst wrote: > This patch isn't really necessary, because GCC will automatically > convert multiplications and divisions by powers of two to use shifts. Sure, but since many << 2 already exists in the net kernel code I feel it's better to use just a

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread David S. Miller
Date:Wed, 10 Jan 2001 17:48:59 +0100 From: antirez <[EMAIL PROTECTED]> The attached patch converts many occurences of '* 4' in the networking code (often used to convert in bytes the TCP data offset and the IP header len) to the faster '<< 2'. The compiler does this for yo

Re: * 4 converted to << 2 for networking code

2001-01-10 Thread Brian Gerst
antirez wrote: > > Hi all, > > The attached patch converts many occurences of '* 4' in the networking code > (often used to convert in bytes the TCP data offset and the IP header len) > to the faster '<< 2'. Since this was a quite repetitive work it's better > if someone double-check it before t