From: Ken Thompson Date: Tue, 25 Nov 2008 01:51:26 +0000 (-0800) Subject: better code for += -= ^= |= and &= X-Git-Tag: weekly.2009-11-06~2611 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9a5c7eab16528cd6b83a7f12b7eb04188e93a857;p=gostls13.git better code for += -= ^= |= and &= R=r OCL=19953 CL=19953 --- diff --git a/src/cmd/6g/gen.c b/src/cmd/6g/gen.c index 3d47360be8..980122b0eb 100644 --- a/src/cmd/6g/gen.c +++ b/src/cmd/6g/gen.c @@ -921,26 +921,35 @@ cgen_asop(Node *n) switch(n->etype) { case OADD: if(!isint[nl->type->etype]) - goto com; + break; if(mpgetfix(nr->val.u.xval) != 1) - goto com; + break; gins(optoas(OINC, nl->type), N, nl); goto ret; case OSUB: if(!isint[nl->type->etype]) - goto com; + break; if(mpgetfix(nr->val.u.xval) != 1) - goto com; + break; gins(optoas(ODEC, nl->type), N, nl); goto ret; + } - com: + if(nl->addable) + switch(n->etype) { case OXOR: case OAND: case OOR: + case OADD: + case OSUB: if(!isint[nl->type->etype]) break; - gins(optoas(n->etype, nl->type), nr, nl); + if(!isint[nr->type->etype]) + break; + regalloc(&n2, nr->type, N); + cgen(nr, &n2); + gins(optoas(n->etype, nl->type), &n2, nl); + regfree(&n2); goto ret; }