]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/8g: introduce temporaries in byte multiplication.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 21 Dec 2012 22:46:16 +0000 (23:46 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 21 Dec 2012 22:46:16 +0000 (23:46 +0100)
Also restore the smallintconst case for binary ops.

Fixes #3835.

R=daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6999043

src/cmd/8g/cgen.c
src/cmd/8g/ggen.c
test/torture.go

index 935831d75120ae28d833544d00e65da766c8e06f..d2935d3992a8c8bf8f3a7dbf8a56c99b1494bbea 100644 (file)
@@ -395,7 +395,15 @@ sbop:      // symmetric binary
        }
 
 abop:  // asymmetric binary
-       if(nl->ullman >= nr->ullman) {
+       if(smallintconst(nr)) {
+               mgen(nl, &n1, res);
+               regalloc(&n2, nl->type, &n1);
+               gmove(&n1, &n2);
+               gins(a, nr, &n2);
+               gmove(&n2, res);
+               regfree(&n2);
+               mfree(&n1);
+       } else if(nl->ullman >= nr->ullman) {
                tempname(&nt, nl->type);
                cgen(nl, &nt);
                mgen(nr, &n2, N);
index d72c2259bd5f701262671ce9bddc67ecdd708f08..641b4389e931dfc77e46f995be2543ef550fe101 100644 (file)
@@ -748,7 +748,7 @@ cgen_shift(int op, int bounded, Node *nl, Node *nr, Node *res)
 void
 cgen_bmul(int op, Node *nl, Node *nr, Node *res)
 {
-       Node n1, n2, *tmp;
+       Node n1, n2, nt, *tmp;
        Type *t;
        int a;
 
@@ -764,10 +764,12 @@ cgen_bmul(int op, Node *nl, Node *nr, Node *res)
                nr = tmp;
        }
 
+       tempname(&nt, nl->type);
+       cgen(nl, &nt);
        regalloc(&n1, t, res);
-       cgen(nl, &n1);
+       cgen(nr, &n1);
        regalloc(&n2, t, N);
-       cgen(nr, &n2);
+       gmove(&nt, &n2);
        a = optoas(op, t);
        gins(a, &n2, &n1);
        regfree(&n2);
index d14d78fd14c531124d76d94d3cf4cc775f13526b..bbf6d347d995afe32a938e5394298a369949591c 100644 (file)
@@ -333,3 +333,7 @@ func ChainDivConst(a int) int {
                17 / 17 / 17 / 17 /
                17 / 17 / 17 / 17
 }
+
+func ChainMulBytes(a, b, c byte) byte {
+       return a*(a*(a*(a*(a*(a*(a*(a*(a*b+c)+c)+c)+c)+c)+c)+c)+c) + c
+}