Commit 6634e343 authored by Russ Cox's avatar Russ Cox

cc, ld: fix more gcc 4.3 -O2 compile bugs

same as https://golang.org/cl/152088
in more files.

Fixes #83.

R=r, r1
https://golang.org/cl/152091
parent 6dbd1429
...@@ -411,8 +411,7 @@ lookup(void) ...@@ -411,8 +411,7 @@ lookup(void)
h += *p++; h += *p++;
} }
n = (p - symb) + 1; n = (p - symb) + 1;
if((int32)h < 0) h &= 0xffffff;
h = ~h;
h %= NHASH; h %= NHASH;
c = symb[0]; c = symb[0];
for(s = hash[h]; s != S; s = s->link) { for(s = hash[h]; s != S; s = s->link) {
......
...@@ -42,8 +42,8 @@ hashstr(char *name) ...@@ -42,8 +42,8 @@ hashstr(char *name)
h = 0; h = 0;
for(cp = name; *cp; h += *cp++) for(cp = name; *cp; h += *cp++)
h *= 1119; h *= 1119;
if(h < 0) // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it.
h = ~h; h &= 0xffffff;
return h; return h;
} }
......
...@@ -384,8 +384,8 @@ lookup(char *symb, int v) ...@@ -384,8 +384,8 @@ lookup(char *symb, int v)
for(p=symb; c = *p; p++) for(p=symb; c = *p; p++)
h = h+h+h + c; h = h+h+h + c;
l = (p - symb) + 1; l = (p - symb) + 1;
if(h < 0) // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it.
h = ~h; h &= 0xffffff;
h %= NHASH; h %= NHASH;
for(s = hash[h]; s != S; s = s->link) for(s = hash[h]; s != S; s = s->link)
if(s->version == v) if(s->version == v)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment