Код: Выделить всё
int gcd(unsigned x, unsigned y) {
return x == 0 ? y : gcd(y % x, x);
}
Код: Выделить всё
gcd(unsigned int, unsigned int): # @gcd(unsigned int, unsigned int)
mov eax, esi
mov edx, edi
test edx, edx
je .LBB0_1
.LBB0_2: # =>This Inner Loop Header: Depth=1
mov ecx, edx
xor edx, edx
div ecx
test edx, edx
mov eax, ecx
jne .LBB0_2
mov eax, ecx
ret
.LBB0_1:
ret
Код: Выделить всё
mov eax, ecx
jne .LBB0_2
mov eax, ecx
Другой пример — два ret в конце функции: один тоже отлично подойдет.
Компилятор просто недостаточно умен или есть причина не удалять дублирования?
Подробнее здесь: https://stackoverflow.com/questions/480 ... structions