In general, the program
extern int x, y;
int main() {
return x + N > y;
}
is optimized into something akin to x + N-1 >= y
for some given N. Example below. Am I reading the assembly right? If so, why does this happen? I thought >
and >=
were virtually identical in in terms of speed, and benchmarks (source) seem to agree?
E.x. for
extern int x, y;
int main() {
return x + 50 > y;
}
the generated assembly is
main:
mov eax, DWORD PTR x[rip]
add eax, 49
cmp eax, DWORD PTR y[rip]
setge al
movzx eax, al
ret
which seems to correspond with x + 49 >= y
(on Godbolt)
12