How is the ">" operator implemented (on 32 bit integers)?

Posted by Ron Klein on Stack Overflow See other posts from Stack Overflow or by Ron Klein
Published on 2010-12-23T06:45:22Z Indexed on 2010/12/23 6:54 UTC
Read the original article Hit count: 233

Let's say that the environment is x86.
How do compilers compile the ">" operator on 32 bit integers.
Logically, I mean. Without any knowledge of Assembly.

Let's say that the high level language code is:

int32 x, y;
x = 123;
y = 456;
bool z;
z = x > y;

What does the compiler do for evaluating the expression x > y?

Does it perform something like (assuming that x and y are positive integers):

w = sign_of(x - y);
if (w == 0)
   // expression is 'false'
else if (w == 1)
   // expression is 'true'
else
   // expression is 'false'

Is there any reference for such information?

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about compiler