Re: What is faster: jne or jge?

Simon Kirby (sim@netnation.com)
Sun, 31 May 1998 10:20:08 -0700 (PDT)


On Sun, 31 May 1998, Tigran Aivazian wrote:

> Hello guys,
>
> Someone asked me a simple but classical question:
>
> What is better:
>
> This: if (some_syscall() < 0) {
> ....
> }
>
> Or this: if (some_syscall() == -1) {
> ....
> }
>
> For some system calls (e.g. lseek(2)) one does not have the luxury of
> choice (because negative results aren't necessarily erroneous) but for
> most others it is only a matter of taste and both are "right"; so I
> answered "since in the first case cc(1) will generate jge
> instruction and in the second jne it depends on what is faster: jge or
> jne".
>
> But what *is* faster? I don't know. And Intel's website doesn't
> immediately face one with something useful, such as a table of timings of
> their instructions or detailed specs of some future generation
> processors but instead greets one with tons of useless b.s. :)

Both instructions are equally expensive. ja, jb, je, jne, jg, jl, jge,
jle take the same number of cycles. It's been this way on every version
of the x86, I believe.

So, (x < 1), (x <= 1), (x == 1), (x != 1), etc., are all the same. This
is only on an Intel chip, however. I'm not sure about others...

Simon-

| Simon Kirby | Systems Administration |
| mailto:sim@netnation.com | NetNation Communications |
| http://www.netnation.com/ | Tech: (604) 684-6892 |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu