From: Ken Thompson Date: Sat, 8 Nov 2008 00:05:17 +0000 (-0800) Subject: byte multiply X-Git-Tag: weekly.2009-11-06~2762 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=79f5697b0268eb1a84a252aa32def124991d3f34;p=gostls13.git byte multiply R=r OCL=18830 CL=18830 --- diff --git a/src/cmd/6g/gen.c b/src/cmd/6g/gen.c index b9f558a608..ba39133ff4 100644 --- a/src/cmd/6g/gen.c +++ b/src/cmd/6g/gen.c @@ -1098,30 +1098,42 @@ ret: void cgen_bmul(int op, Node *nl, Node *nr, Node *res) { - Node n1, n2; + Node n1, n2, n3; Type *t; int a; - t = types[TUINT16]; - if(issigned[nl->type->etype]) - t = types[TINT16]; - if(nl->ullman >= nr->ullman) { - regalloc(&n1, t, nl); + regalloc(&n1, nl->type, res); cgen(nl, &n1); - regalloc(&n2, t, nr); + regalloc(&n2, nr->type, N); cgen(nr, &n2); } else { - regalloc(&n2, t, nr); + regalloc(&n2, nr->type, N); cgen(nr, &n2); - regalloc(&n1, t, nl); + regalloc(&n1, nl->type, res); cgen(nl, &n1); } + + // copy to short registers + t = types[TUINT16]; + if(issigned[nl->type->etype]) + t = types[TINT16]; + + regalloc(&n3, t, &n2); + cgen(&n2, &n3); + regfree(&n3); + + regalloc(&n3, t, &n1); + cgen(&n1, &n3); + a = optoas(op, t); gins(a, &n2, &n1); - gmove(&n1, res); + cgen(&n3, &n1); + cgen(&n1, res); + regfree(&n1); regfree(&n2); + regfree(&n3); } void