Re: gcc anomalities (fwd)

Tom May (ftom@netcom.com)
30 Dec 1996 11:36:15 -0800


Neptho T <Neptho@hagan.reno.nv.us> writes:

> I've been looking at the assembly code generated by gcc for some of the
> Linux code, and there seem to be some weird anomolies...
>
> In net/ipv4/tcp_output.c there are a few references to "sk->rcvbuf/2" and
> "sk->rmem_alloc/2". For some reason which I'm trying to ascertain, gcc
> generates the awkward instruction sequence:
>
> 77:tcp_output.c **** window = sk->rcvbuf/2;
> 1473 .LM10:
> 1474 003a 8B861C01 movl 284(%esi),%eax
> 1474 0000
> 1475 0040 C1E81F shrl $31,%eax
> 1476 0043 03861C01 addl 284(%esi),%eax
> 1476 0000
> 1477 0049 89C2 movl %eax,%edx
> 1478 004b C1FA01 sarl $1,%edx

That is to get the rounding correct for negative numbers when using
shift to do a signed division. The code would be simpler if the
numerator were unsigned.

Tom.