[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200702091036.58474.dada1@cosmosbay.com>
Date: Fri, 9 Feb 2007 10:36:58 +0100
From: Eric Dumazet <dada1@...mosbay.com>
To: David Miller <davem@...emloft.net>
Cc: ak@...e.de, linux@...izon.com, akepner@....com,
netdev@...r.kernel.org
Subject: Re: [PATCH] NET : change layout of ehash table
On Friday 09 February 2007 10:15, David Miller wrote:
> From: Eric Dumazet <dada1@...mosbay.com>
> Date: Fri, 9 Feb 2007 10:06:24 +0100
>
> > Yes, but a decent C compiler for such targets should not use a
> > multiply instruction to perform a (idx * 12) operation... :)
>
> Good point.
>
> Actually, I could never get GCC to avoid a divide on sparc64 for
> certain kinds of pointer arithmetic when the elements were not
> a power of two. It probably has something to do with signedness.
>
> I think I narrowed is down to the fact that you can't legally replace
> a signed divide with shift/add/subtract. But I could be remembering
> things wrong.
Thats strange, because pointer arithmetic is unsigned...
I dont know when gcc started to use reciprocal division, maybe your gcc was
very old ?
$ cat div.c
struct s1 { int pad[3]; };
unsigned long diffptr(struct s1 *a, struct s1 *b)
{
return a - b;
}
If compiled on i386 , gcc-4.1.1 :
$ gcc -O2 -fomit-frame-pointer -S div.c
diffptr:
movl 4(%esp), %eax
subl 8(%esp), %eax
sarl $2, %eax
imull $-1431655765, %eax, %eax
ret
If compiled on x86_64 , gcc-4.1.1:
diffptr:
subq %rsi, %rdi
movabsq $-6148914691236517205, %rax
sarq $2, %rdi
imulq %rax, %rdi
movq %rdi, %rax
ret
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists