Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"12-05-08 - lrotl"

2 Comments -

1 – 2 of 2
Blogger won3d said...

So, GCC manages to do some nice things. "(x<25) + (x>>7)" automatically turns into rotl, and accessing the high 32-bits of the 64-bit multiplication result doesn't have any ridiculousness. Maybe some extra MOVs.

Anyway, combining chocolate/peanut butter, using all 64 bits of the MUL seems like it makes a pretty good/fast hash. I'm still trying to figure out a good way to handle the final mix with MUL, which seems expensive there.

December 6, 2008 at 9:24 PM

Blogger won3d said...

OK I think I figured out a good way to do the last, NUL-containing word. The trick is to overlap the multiply with the search for the NUL. What seems to work pretty well is to first check if the first byte is NUL, then kick off the multiply, then find the NUL byte to compute a mask you use on the eventual product. The mask should include the valid and NUL bytes, but zero-out the following garbage bytes.

Also, it is probably a good idea to incorporate the length of the string in the hash somehow, although less important for NUL-terminated strings.

December 7, 2008 at 11:09 AM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.