Quick question, assuming beforehand
mov eax, 0
which is more efficient?
inc eax
inc eax
or
add eax, 2
Also, in case the two inc
s are faster, do compilers (say, the GCC) commonly (i.e. w/o aggressive optimization flags) optimize var += 2
to it?
PS: Don't bother to answer with a variation of "don't prematurely optimize", this is merely academic interest.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…