---------- Forwarded message ----------
Date: Thu, 26 Dec 1996 05:53:54 -0800 (PST)
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
and:
84:tcp_output.c **** window -= sk->rmem_alloc/2;
1495 .LM15:
1496 005e 8B4608 movl 8(%esi),%eax
1497 0061 C1E81F shrl $31,%eax
1498 0064 034608 addl 8(%esi),%eax
1499 0067 C1F801 sarl $1,%eax
1500 006a 29C2 subl %eax,%edx
for these code sequences.
I'm wondering if we can replace some of the / 2 with >> 1 instead? The
code generated is much faster:
movl 8(%ebp),%eax
sarl $1,%eax
which is two instructions shorter than "shrl/addl/sarl".
Toshi