HS> Bit shifting will ALWAYS be faster than multiplying.
MW>According to a book I am reading right now. Bit shifting is faster by a
MW>factor of around 3 times. You just have to be careful if you shift too
MW>far you may lose significant bits. :-(
HS> My point exactly, you should forward this message to the Chris Downs.
No. The point was made that substituting a multiply with two bit shifts
and two adds makes for a performance plus.
The problem is that I've bench marked it. Counting cycles
is not a satisfactory substitute. The add/bit shift has more code. Did
you count the cycles needed to load the code into the instruction
pipeline (for example)???
It's _so_simple_ to get the exact answer by running such a simple test.
I *know* that substituting an bit shifts/adds for an integer multiply
on a 386 is a performance loser. (Because I tested it) I also know that
substituting a bit shift for a multiply by a constant power of two is a
waste of effort for every compiler I use. (Again because I tested it.)
Since I don't like to play lose/lose scenarios, I'll pass on the above
advice. (But I certainly can be swayed by reliable evidence. How
about bench marking your performace "improvements" and supplying
us with the results?? It would be quite educational!)
---
þ Blue Wave/QWK v2.12 þ
---------------
* Origin: St. Louis Users Group (1:100/4)
|