对于这段 C 代码:
uint64_t roundUp(uint64_t value, uint32_t blockSize)
{
return (value + blockSize - 1) & ~(blockSize - 1);
}
gcc 4.6 -O3 生成以下程序集:
roundUp(unsigned long, unsigned int):
.LFB0:
.cfi_startproc
movl %esi, %edx
movl %esi, %esi
leaq -1(%rdi,%rsi), %rax
negl %edx
andl %edx, %eax
ret
.cfi_endproc
谁能告诉我为什么要这样做?
movl %esi, %esi