On Friday 03 February 2006 12:58, Andreas Mohr wrote: > - adev->tx_head = (head + 1) % TX_CNT; > + /* slower: adev->tx_head = (head + 1) % TX_CNT; */ > + adev->tx_head = head + 1; > + if (adev->tx_head >= TX_CNT) > + adev->tx_head = 0;
struct a { int tx_head; }; #define TX_CNT 16 void f(struct a *adev, int head) { adev->tx_head = (head + 1) % TX_CNT; } void g(struct a *adev, int head) { adev->tx_head = head + 1; if (adev->tx_head >= TX_CNT) adev->tx_head = 0; } gcc -Os -S t.c -fomit-frame-pointer -falign-functions=1 -falign-labels=1 -falign-loops=1 -falign-jumps=1 -mtune=i386 -march=i386 produces: f: movl 8(%esp), %eax incl %eax movl $16, %edx movl %edx, %ecx cltd idivl %ecx movl 4(%esp), %eax movl %edx, (%eax) ret .size f, .-f .globl g .type g, @function g: movl 4(%esp), %edx movl 8(%esp), %eax incl %eax movl %eax, (%edx) cmpl $15, %eax jle .L6 movl $0, (%edx) .L6: ret .size g, .-g .ident "GCC: (GNU) 4.0.0" Well, gcc obviously failed to realize that "% 16" == "& 15". I'll file a bug. Meanwhile, with & 15 f() is better: f: movl 8(%esp), %eax incl %eax andl $15, %eax movl 4(%esp), %edx movl %eax, (%edx) ret .size f, .-f .globl g .type g, @function g: movl 4(%esp), %edx movl 8(%esp), %eax incl %eax movl %eax, (%edx) cmpl $15, %eax jle .L6 movl $0, (%edx) .L6: ret .size g, .-g .ident "GCC: (GNU) 4.0.0" -- vda - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html