DM> Are you SURE that two shift operations followed by an addition is
DM> really faster than the hardware-optimized integer multiplication?
DM> Perhaps on an 8086... but on an 80486? Probably not...
NJ> a shift operation on a pentium takes 1 clockcycle where an integer
NJ> multiplication takes 9 for 32bit registers and 11 for 16bit
NJ> I roughly calculated the number of clockcycles for both calculations:
NJ> x+(y 4 clockcycles
NJ> x+y*320 => 11 (32bit), 13 (16bit)
NJ> so using shifts is still the fastest way.
I suppose it's possible. There are a couple of aspects to running the
code that you neglected to include in your analysis. (Like loading the
code into the pipeline.) It would be easy enough to benchmark the code
and that's the _only_ way you could get a good answer to the question.
And perhaps a pentium would be faster with the shifting/adding. All I
_know_ is that the above tchnique is slower than .... on a 386.
---
þ Blue Wave/QWK v2.12 þ
---------------
* Origin: St. Louis Users Group (1:100/4)
|