1
0
mirror of https://github.com/golang/go synced 2024-11-26 19:51:17 -07:00

unsigned divide by fn()

R=r
OCL=18351
CL=18351
This commit is contained in:
Ken Thompson 2008-11-03 13:27:16 -08:00
parent 6b05518553
commit 250ec1665a

View File

@ -907,7 +907,7 @@ void
dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx) dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx)
{ {
int a; int a;
Node n3; Node n3, n4;
Type *t; Type *t;
t = nl->type; t = nl->type;
@ -919,25 +919,25 @@ dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx)
} }
a = optoas(op, t); a = optoas(op, t);
if(!issigned[t->etype]) {
nodconst(&n3, t, 0);
gmove(&n3, dx);
}
regalloc(&n3, nr->type, N); regalloc(&n3, nr->type, N);
if(nl->ullman >= nr->ullman) { if(nl->ullman >= nr->ullman) {
cgen(nl, ax); cgen(nl, ax);
if(issigned[t->etype]) if(!issigned[t->etype]) {
nodconst(&n4, t, 0);
gmove(&n4, dx);
} else
gins(optoas(OFOR, t), N, N); gins(optoas(OFOR, t), N, N);
cgen(nr, &n3); cgen(nr, &n3);
gins(a, &n3, N);
} else { } else {
cgen(nr, &n3); cgen(nr, &n3);
cgen(nl, ax); cgen(nl, ax);
if(issigned[t->etype]) if(!issigned[t->etype]) {
nodconst(&n4, t, 0);
gmove(&n4, dx);
} else
gins(optoas(OFOR, t), N, N); gins(optoas(OFOR, t), N, N);
gins(a, &n3, N);
} }
gins(a, &n3, N);
regfree(&n3); regfree(&n3);
if(op == ODIV) if(op == ODIV)