Re: What is faster: jne or jge?

Jeanette Pauline Middelink (middelin@polyware.nl)
Sun, 31 May 1998 23:29:37 +0200


On Sun, May 31, 1998 at 10:20:08AM -0700, Simon Kirby wrote:
> On Sun, 31 May 1998, Tigran Aivazian wrote:
[snobbeld]
> > 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...
Errr? surely you mean 0 here?

But the starting test was an equality test against -1, not 0, so
gcc would have to generate an 'cmp %ax,$-1; jne' or something analogue.

The test for <0 can be done wit a lone jb ...
(assuming the flags are correctly set up, otherwise a
'or %eax,%eax' would be needed)

So testing against <0 is faster than testing against == -1.

Met vriendelijke groet,
Pauline Middelink

-- 
PGP Key fingerprint = DE 6B D0 D9 19 AD A7 A0  58 A3 06 9D B6 34 39 E2
For more details look at my website http://www.polyware.nl/~middelin

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