]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6g: restore magic multiply for /=, %=.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 13 Apr 2012 08:12:31 +0000 (10:12 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 13 Apr 2012 08:12:31 +0000 (10:12 +0200)
Also enables turning /= 2 in a right shift.

Part of issue 2230.

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6012049

src/cmd/6g/ggen.c

index 02e67d6d41e5a49080c34babed7186547ae98be5..434ee32e35516f26622a52572990ae6be1ee431e 100644 (file)
@@ -389,7 +389,9 @@ cgen_asop(Node *n)
 hard:
        n2.op = 0;
        n1.op = 0;
-       if(nr->ullman >= nl->ullman || nl->addable) {
+       if(nr->op == OLITERAL) {
+               // don't allocate a register for literals.
+       } else if(nr->ullman >= nl->ullman || nl->addable) {
                regalloc(&n2, nr->type, N);
                cgen(nr, &n2);
                nr = &n2;