diff --git a/src/cmd/cc/lex.c b/src/cmd/cc/lex.c index ff80bfb324a..9fbf3a3acdd 100644 --- a/src/cmd/cc/lex.c +++ b/src/cmd/cc/lex.c @@ -411,8 +411,7 @@ lookup(void) h += *p++; } n = (p - symb) + 1; - if((int32)h < 0) - h = ~h; + h &= 0xffffff; h %= NHASH; c = symb[0]; for(s = hash[h]; s != S; s = s->link) { diff --git a/src/cmd/ld/go.c b/src/cmd/ld/go.c index aa006a847ef..8f0e66d3306 100644 --- a/src/cmd/ld/go.c +++ b/src/cmd/ld/go.c @@ -42,8 +42,8 @@ hashstr(char *name) h = 0; for(cp = name; *cp; h += *cp++) h *= 1119; - if(h < 0) - h = ~h; + // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it. + h &= 0xffffff; return h; } diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 99a76558d37..4a518c79b1e 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -384,8 +384,8 @@ lookup(char *symb, int v) for(p=symb; c = *p; p++) h = h+h+h + c; l = (p - symb) + 1; - if(h < 0) - h = ~h; + // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it. + h &= 0xffffff; h %= NHASH; for(s = hash[h]; s != S; s = s->link) if(s->version == v)