3 ms·
For an integer, if the pre-increment value isn't used, GCC at least will generate the same code, even with optimization turned off: int pre(int a) {
by danellis 12y ago
For an integer, if the pre-increment value isn't used, GCC at least will generate the same code, even with optimization turned off:
int pre(int a) { int post(int a) {
++a; a++;
return a; return a;
} }
pre: post:
.LFB0: .LFB1:
.cfi_startproc .cfi_startproc
pushq %rbp pushq %rbp
.cfi_def_cfa_offset 16 .cfi_def_cfa_offset 16
.cfi_offset 6, -16 .cfi_offset 6, -16
movq %rsp, %rbp movq %rsp, %rbp
.cfi_def_cfa_register 6 .cfi_def_cfa_register 6
movl %edi, -4(%rbp) movl %edi, -4(%rbp)
addl $1, -4(%rbp) addl $1, -4(%rbp)
movl -4(%rbp), %eax movl -4(%rbp), %eax
popq %rbp popq %rbp
.cfi_def_cfa 7, 8 .cfi_def_cfa 7, 8
ret ret