Re: [PATCH] Improving send_sigio() scalability

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Wed, 26 May 1999 15:58:02 +0200


> > > Why don't you use != when that is what you mean?

Linus Torvalds wrote:
> It used to do noticeably better compiler-wise. I don't know if newer
> versions of gcc have made ^ and != generate the same code.

Odd.

I would expect != to generate better code than ^: != uses `cmp'
instruction, ^ uses `xor' unless the compiler gets clever.

Since `cmp' does not clobber a useful value but `xor' does, and the
`cond1 && cond2 && cond3' sequence has to be a sequence of test, branch,
test, branch etc., I'd expect != to use fewer instructions overall than ^.

Are you thinking of the sequence `if ((a ^ b) | (c ^ d))' etc. instead?
That might be marginally smaller and faster with xor because branches
are optimised away. But I wouldn't expect such speed from `if ((a ^ b)
&& (c ^ d))'.

-- Jamie

because the latter
clobbers a value which must be clobbered

I would imagine `if ((a ^ b) && (c ^ d))' to generate code like this:

xorl %eax,%ebx # must copy %ebx if required later
jz 0f
xorl %ecx,%edx
jz 0f
# body of if
0:

And `if ((a != b) && (c != d))' to generate code like this:

cmpl %eax,%ebx

>
> Linus
>
>
> Please read the FAQ at http://www.tux.org/lkml/
>
> ------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/