Saves one MOVW and one register during the fast div/mod introduced in CL
6819123.
linux/arm (armv5)
benchmark old ns/op new ns/op delta
BenchmarkInt64Mod1 12 12 +7.50%
BenchmarkUint16Mod2 7 7 +0.28%
BenchmarkUint16Mod4 7 7 -0.28%
BenchmarkUint64Mod1 15 11 -23.72%
BenchmarkInt8Neg 8 7 -17.66%
BenchmarkInt16Neg 8 7 -17.66%
BenchmarkInt32Neg 5 5 -9.04%
BenchmarkUint8Neg 7 6 -14.35%
BenchmarkUint16Neg 8 7 -17.66%
BenchmarkUint32Neg 5 5 -9.04%
R=rsc
CC=golang-dev
https://golang.org/cl/
6842045
cgen(Node *n, Node *res)
{
Node *nl, *nr, *r;
- Node n1, n2, n3, f0, f1;
+ Node n1, n2, f0, f1;
int a, w, rg;
Prog *p1, *p2, *p3;
Addr addr;
case OMINUS:
regalloc(&n1, nl->type, N);
cgen(nl, &n1);
- nodconst(&n3, nl->type, 0);
- regalloc(&n2, nl->type, res);
- gmove(&n3, &n2);
- gins(optoas(OSUB, nl->type), &n1, &n2);
- gmove(&n2, res);
+ nodconst(&n2, nl->type, 0);
+ gins(optoas(OMINUS, nl->type), &n2, &n1);
+ gmove(&n1, res);
regfree(&n1);
- regfree(&n2);
goto ret;
// symmetric binary
a = ASUBD;
break;
+ case CASE(OMINUS, TINT8):
+ case CASE(OMINUS, TUINT8):
+ case CASE(OMINUS, TINT16):
+ case CASE(OMINUS, TUINT16):
+ case CASE(OMINUS, TINT32):
+ case CASE(OMINUS, TUINT32):
+ case CASE(OMINUS, TPTR32):
+ a = ARSB;
+ break;
+
case CASE(OAND, TINT8):
case CASE(OAND, TUINT8):
case CASE(OAND, TINT16):