PDA

View Full Version : Fastest multiplication (case pointer, in Delphi 7)



cronodragon
16-10-2006, 04:10 PM
I have a pointer "Linea" which I want to move to a certain position, so I used shl multiplications to optimize the operation. But taking a look to the CPU window, it seems to be slower than using normal multiplication. These are screenshots for 3 different operations to position the pointer:

http://www.teleportmedia.com/personal/mulpnt.jpg

And Inc() isn't replaced by the inc operator.

dmantione
16-10-2006, 04:17 PM
It is best to leave these things to the compiler to decide. About any compiler you find will optimize constant multiplication. So, in this case Delphi optimizes it to LEA, which indeed is the fastest way to multiply with 3.

cronodragon
16-10-2006, 04:32 PM
Then the old trick doesn't work anymore :cry: