guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does anyone have a better scm_string_hash ?


From: Allister MacLeod
Subject: Re: Does anyone have a better scm_string_hash ?
Date: Mon, 17 Nov 2003 11:48:20 -0500
User-agent: Mutt/1.5.4i

On Mon, Nov 17, 2003 at 05:29:48PM +0100, Marius Vollmer wrote:
> Marius Vollmer <address@hidden> writes:
> > Just for kicks, I'm now going to see what kind of code GCC generates
> > for h*37 as compared to (h<<5) + (h<<2) + h...
> Interesting.  For h = a + (h<<5) + (h<<2) + h we get this sequence
> (one line is one machine instruction):
>     x = h
>     x = x << 5
>     a = a + x
>     a = a + h*4
>     h = a + h
> and for h = a + h*37 we get
>     x = h + h*8
>     x = h + x*4
>     h = x + a*1
> which is nearly twice as clever...

Just for reference, what are the timings on a Pentium for these
instructions?  I assume from your pleased comments that
assign-from-plus-and-multiply is sufficiently fast that two of them
are less costly than a pair of assign-from-plus, an assign-from-shift,
and an assignment.  I'm curious as to why the last line of the second
way ends up being h=x+a*1, instead of h=x+a.  Are a series of
same-width instructions faster than ones with different widths?
(gawd, CISC rox, bleh)

Cheers,
 Allister

-- 
Allister MacLeod <address@hidden> | http://amacleod.is-a-geek.org/
 Elen síla lúmenn'omentielvo.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]