On 2017-08-15 14:24 +0800, Xi Ruoyao wrote: > In your code: > > asm( > "addl $1,(%1)" > : "=r"(res) > : "rdi"(z) > : "memory" > ); > > "res" is an unused output variable. So GCC just optimize it away. You > should use "asm volatile". And I think it's better to rewrite it: asm( "addl $1, (%0)" :: "rdi"(z) : memory ); It would eliminate the unused variable res. -- Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University