Skip to content

Adler32 Hash; clang 7.0 is 1.3x slower than gcc 7.3 #34915

@nigeltao

Description

@nigeltao
mannequin
Bugzilla Link 35567
Version 7.0
OS Linux
Attachments Adler32 C implementation
CC @adibiagio,@topperc,@RKSimon,@rotateright

Extended Description

adler32-standalone.c (attached, also at https://github.com/google/wuffs/blob/master/script/adler32-standalone.c) is some straight C code to calculate the standard Adler32 hash, used by the zlib format.

Measuring throughput on a recent Debian Testing system (clang 5.0 and gcc 7.2), Intel x86_64 Broadwell, suggests that clang's generated code is 1.3x slower.

$ clang-5.0 -O3 adler32-standalone.c; ./a.out
2311 MiB/s, clang 5.0.0 (tags/RELEASE_500/rc2)
$ gcc -O3 adler32-standalone.c; ./a.out
3052 MiB/s, gcc 7.2.1 20171025

The core loop (manually unrolled 8 times) is:

while (p < end0) {
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions