From e69f12ae1d2e2206c6104acee31c6639bb93705f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 23 Nov 2009 14:23:14 -0800 Subject: [PATCH] two more if(h<0) that gcc 4.3 -O2 miscompiles R=r https://golang.org/cl/160044 --- src/cmd/cc/lexbody | 3 +-- src/libmach/obj.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cmd/cc/lexbody b/src/cmd/cc/lexbody index f5a250fcf7d..ba5eda8242f 100644 --- a/src/cmd/cc/lexbody +++ b/src/cmd/cc/lexbody @@ -226,8 +226,7 @@ lookup(void) for(p=symb; c = *p; p++) h = h+h+h + c; l = (p - symb) + 1; - if(h < 0) - h = ~h; + h &= 0xffffff; h %= NHASH; c = symb[0]; for(s = hash[h]; s != S; s = s->link) { diff --git a/src/libmach/obj.c b/src/libmach/obj.c index aa914e2c761..dacb2ae1fa7 100644 --- a/src/libmach/obj.c +++ b/src/libmach/obj.c @@ -257,9 +257,7 @@ objlookup(int id, char *name, int type, uint sig) h = *name; for(cp = name+1; *cp; h += *cp++) h *= HASHMUL; - if(h < 0) - h = ~h; - h &= (NHASH-1); + h &= NHASH-1; if (type == 'U' || type == 'b' || islocal(type)) { for(sp = hash[h]; sp; sp = sp->next) if(strcmp(sp->s.name, name) == 0) {