summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-09-15 15:03:10 -0700
committerKen Thompson <ken@golang.org>2008-09-15 15:03:10 -0700
commit7291524981aa0b267ef042ba4bb5bb258c01bda0 (patch)
tree328ea42d7da0defe9ce6c1d740ad2bdf7b6bfcc2
parentf0588e3f780d482ba20cb988f9f52cec189a943b (diff)
downloadgolang-7291524981aa0b267ef042ba4bb5bb258c01bda0.tar.gz
bug - divide and mod of a byte
R=r OCL=15370 CL=15370
-rw-r--r--src/cmd/6g/gen.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/cmd/6g/gen.c b/src/cmd/6g/gen.c
index fcd070c47..34b14ec65 100644
--- a/src/cmd/6g/gen.c
+++ b/src/cmd/6g/gen.c
@@ -1001,26 +1001,34 @@ dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx)
{
int a;
Node n3;
+ Type *t;
- a = optoas(op, nl->type);
+ t = nl->type;
+ if(t->width == 1) {
+ if(issigned[t->etype])
+ t = types[TINT32];
+ else
+ t = types[TUINT32];
+ }
+ a = optoas(op, t);
- if(!issigned[nl->type->etype]) {
- nodconst(&n3, nl->type, 0);
+ if(!issigned[t->etype]) {
+ nodconst(&n3, t, 0);
gmove(&n3, dx);
}
regalloc(&n3, nr->type, N);
if(nl->ullman >= nr->ullman) {
cgen(nl, ax);
- if(issigned[nl->type->etype])
- gins(optoas(OFOR, nl->type), N, N);
+ if(issigned[t->etype])
+ gins(optoas(OFOR, t), N, N);
cgen(nr, &n3);
gins(a, &n3, N);
} else {
cgen(nr, &n3);
cgen(nl, ax);
- if(issigned[nl->type->etype])
- gins(optoas(OFOR, nl->type), N, N);
+ if(issigned[t->etype])
+ gins(optoas(OFOR, t), N, N);
gins(a, &n3, N);
}
regfree(&n3);