What if all computers on the world had to wait for each others LEA instructions to complete?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
lea esi , [ eax + ecx * 4]
lea edi , [ edx + ebx * 4]
Yes, in theory (depending on which CPU) it's possible for multiple LEA instructions that don't depend on each other to be "in fight" at the same time on the same CPU, and (in theory) they may even pass through the stages of that CPU in step (e.g. both being started in the same cycle and both being retired in the same cycle).
Of course it depends a lot on which CPU - it certainly can't happen with an old 8086. I'm not too sure if it will happen with the latest "Sandy Bridge" or "Haswell" CPUs or not (for both these CPUs there's multiple ALUs where 2 of them do LEA, but one ALU does "normal LEA" and the other "fast LEA", so while 2 LEAs could happen in parallel one would finish faster and be retired sooner).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
mov [ebp+4], 0
.loopstart:
mov eax, [ebp+4]
cmp eax, 100000000
jae .loopend
push esi
push edi
push ebx
lea esi, [eax + ecx]
lea edi, [edx + ebx]
pop ebx
pop edi
pop esi
mov eax, [ebp+4]
inc eax
mov [ebp+4], eax
jmp .loopstart
You'd be looking at a difference of 1/15th of the time if everything took exactly one cycle, but that's of it's own a shabby assumption to go on. Plus Windows' GetTickCount is pretty imprecise.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:Playing the dumb compiler says: (and the way you're doing imports says the compiler is dumb)
Surely if the compiler was slightly smart, it'd optimise it down to a single "printf("%u ticks",GetTickCount@0()-GetTickCount@0());" line.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.