3 ms·
> The 64 bit width version is shorter, and so conceivably faster. Without profiling there's no way to tell on modern processors.
by Narishma 11y ago
> The 64 bit width version is shorter, and so conceivably faster.
Without profiling there's no way to tell on modern processors.
- nwmcsween 11y agoSeriously, you think movzwl -4(%rbp), %eax addl $1, %eax movw %ax, -4(%rbp) will be on par with addq $1, -16(%rbp)
- DSMan195276 11y agoModern processors are pretty crazy beasts. He right in saying it's impossible to say for sure without some hard numbers or profiling. Comparatively, while one is three instructions and the other is one, that single instruction is still doing everything the other three are doing. The only reason they aren't both one instruction seems to be that `addw` must not being a thing (Why, I don't know). Since the I/O done by both will be nearly identical, and the addition's should be very comparable in speed, it's not crazy to say they should perform basically the same. If you compiled with -O2 I bet you'd see almost identical code, since it would probably remove the memory access.