]> Cypherpunks repositories - gostls13.git/commitdiff
byte multiply
authorKen Thompson <ken@golang.org>
Sat, 8 Nov 2008 00:05:17 +0000 (16:05 -0800)
committerKen Thompson <ken@golang.org>
Sat, 8 Nov 2008 00:05:17 +0000 (16:05 -0800)
R=r
OCL=18830
CL=18830

src/cmd/6g/gen.c

index b9f558a60859da48aec3decfe20d4481cb7d1a92..ba39133ff46ec1846823f23a686d536101f2dcb7 100644 (file)
@@ -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