Does anyone know if GCC v4.x optimizes automatically the incr i++; to ++i; ?
Name:
Anonymous2009-05-29 16:44
They are not the same, even when used as an expression-instruction:
++i; increments the value of i first and then puts it on the stack, to be immediately after cleared out (since the value isn't used)
i++; first puts 'i' on the stack, duplicates it, increments one 'i' and puts it back to 'i', leaving the unchanged value on the stack to be used if needed (cleared out after, as it isn't used)
to summarize, 'i++' uses one duplicate more than '++i'