https://www.godbolt.org/z/5b594qKd5
static int Upsilon(int a, int b)
{
int n = 100;
while (n > 0)
{
int t = a + b;
a = b;
b = t;
n = n - 1;
}
return a;
}
Program:Upsilon(int,int):int (FullOpts):
mov eax, 100
jmp SHORT G_M57122_IG04
align [0 bytes for IG03]
G_M57122_IG03: ;; offset=0x0007
mov r8d, ecx
mov ecx, edx
mov edx, r8d
G_M57122_IG04: ;; offset=0x000F
add ecx, edx
dec eax
test eax, eax
jg SHORT G_M57122_IG03
mov ecx, edx
mov eax, ecx
ret
It emits an unconditional jmp SHORT G_M57122_IG04 into the loop body at the start of the function.
Instead it could fall into it. For example, MSVC: https://godbolt.org/z/Pr5bTn999
https://www.godbolt.org/z/5b594qKd5
It emits an unconditional
jmp SHORT G_M57122_IG04into the loop body at the start of the function.Instead it could fall into it. For example, MSVC: https://godbolt.org/z/Pr5bTn999