考虑以下代码:
int isqrt(int x) {
unsigned int r;
r = x >> 7;
r += x / r;
r >>= 1;
r += x / r;
r >>= 1;
r += x / r;
r >>= 1;
return r;
}
gcc -O3 isqrt.c -S
生成这个:
_isqrt:
pushl %ebx
movl 8(%esp), %ecx
movl %ecx, %ebx
sarl $7, %ebx
movl %ecx, %eax
xorl %edx, %edx ; huh?
divl %ebx
addl %eax, %ebx
shrl %ebx
movl %ecx, %eax
xorl %edx, %edx ; huh?
divl %ebx
addl %eax, %ebx
shrl %ebx
movl %ecx, %eax
xorl %edx, %edx ; huh?
divl %ebx
addl %ebx, %eax
shrl %eax
popl %ebx
ret
为什么%edx
接缝无故清除3次?