shift bit & performance?

Jakob Oestergaard jakob at unthought.net
Wed Oct 22 04:45:08 EDT 2003


On Tue, Oct 21, 2003 at 02:33:33PM -0500, Dean Johnson wrote:
> On Tue, 2003-10-21 at 14:32, Eduardo Cesar Cabrera Flores wrote:
> > Hi, 
> > 
> > sometime ago, somebody sent an info about performance working with "<<" & 
> > ">>" doing shift bits instead of using "*" or "/"
> >  Could anybody help me about it?
> > 
> 
> There is certainly performance to be had from using a logical shift instead of a 
> multiply or divide, but its of declining value. I am fairly sure that with modern
> compilers you do a integer divide by a constant power of 2, that it will generate
> a logical shift. That aint rocket science.
> 

It used to be true that shifts were 'better' on Intel x86 processors,
but it is not that simple anymore.

On the P4 for example, a sequence of 'add's is cheaper than a left 
shift, for three adds or less (because the latency on the shift opcode 
has increased compared to earlier generations).  

-- 
................................................................
:   jakob at unthought.net   : And I see the elder races,         :
:.........................: putrid forms of man                :
:   Jakob Østergaard      : See him rise and claim the earth,  :
:        OZ9ABN           : his downfall is at hand.           :
:.........................:............{Konkhra}...............:
_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list