chennqqi / smhasher

Automatically exported from code.google.com/p/smhasher
0 stars 0 forks source link

Very slow with gcc 4.4.4 #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It's slow in my machine. A Slackware 13.1 box with a Core i5 650 3.2 GHz.

It's only 500 MB/s, where OpenSSL MD5 is 600 MB/s.

The reason is the (broken) optimizer of gcc 4.4.4 that does things like:

g++ -g -c -O2 MurmurHash3.cpp -o MurmurHash3.o

-> .cpp
    k1 *= c1;
-> .asm
 152:   8d 14 80                lea    (%eax,%eax,4),%edx
 155:   8d 14 90                lea    (%eax,%edx,4),%edx
 158:   c1 e2 03                shl    $0x3,%edx
 15b:   29 c2                   sub    %eax,%edx
 15d:   8d 14 d2                lea    (%edx,%edx,8),%edx
 160:   8d 14 90                lea    (%eax,%edx,4),%edx
 163:   8d 14 d0                lea    (%eax,%edx,8),%edx
 166:   8d 14 90                lea    (%eax,%edx,4),%edx
 169:   8d 14 50                lea    (%eax,%edx,2),%edx
 16c:   8d 14 90                lea    (%eax,%edx,4),%edx
 16f:   8d 14 92                lea    (%edx,%edx,4),%edx
 172:   8d 14 50                lea    (%eax,%edx,2),%edx
 175:   8d 04 d0                lea    (%eax,%edx,8),%eax
 178:   8d 14 c5 00 00 00 00    lea    0x0(,%eax,8),%edx
 17f:   29 d0                   sub    %edx,%eax

changing the c1,c2,c3,c4 constants as global variables, fixes that, and I get 
3000 MB/s.

Original issue reported on code.google.com by amadva...@gmail.com on 12 Apr 2011 at 6:31

GoogleCodeExporter commented 9 years ago

Original comment by tanj...@gmail.com on 11 May 2012 at 5:40