mirror of
https://github.com/golang/go
synced 2024-11-22 22:10:03 -07:00
cmd/6c, cmd/8c: avoid generating long multiplication when not necessary.
On amd64 benchmark old ns/op new ns/op delta BenchmarkHashStringSpeed 91 74 -18.49% BenchmarkHashInt32Speed 54 45 -17.88% BenchmarkHashInt64Speed 76 58 -23.53% BenchmarkHashStringArraySpeed 231 188 -18.61% Fixes #5367. R=golang-dev, iant, dave, daniel.morsing, ality, rsc CC=golang-dev https://golang.org/cl/9040043
This commit is contained in:
parent
62891fb811
commit
2c0b00744f
@ -392,13 +392,13 @@ cgen(Node *n, Node *nn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(o == OMUL) {
|
if(o == OMUL || o == OLMUL) {
|
||||||
if(l->addable >= INDEXED) {
|
if(l->addable >= INDEXED) {
|
||||||
t = l;
|
t = l;
|
||||||
l = r;
|
l = r;
|
||||||
r = t;
|
r = t;
|
||||||
}
|
}
|
||||||
/* should favour AX */
|
reg[D_DX]++; // for gopcode case OMUL
|
||||||
regalloc(&nod, l, nn);
|
regalloc(&nod, l, nn);
|
||||||
cgen(l, &nod);
|
cgen(l, &nod);
|
||||||
if(r->addable < INDEXED || hardconst(r)) {
|
if(r->addable < INDEXED || hardconst(r)) {
|
||||||
@ -410,6 +410,7 @@ cgen(Node *n, Node *nn)
|
|||||||
gopcode(OMUL, n->type, r, &nod); /* addressible */
|
gopcode(OMUL, n->type, r, &nod); /* addressible */
|
||||||
gmove(&nod, nn);
|
gmove(&nod, nn);
|
||||||
regfree(&nod);
|
regfree(&nod);
|
||||||
|
reg[D_DX]--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,13 +404,13 @@ cgen(Node *n, Node *nn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(o == OMUL) {
|
if(o == OMUL || o == OLMUL) {
|
||||||
if(l->addable >= INDEXED) {
|
if(l->addable >= INDEXED) {
|
||||||
t = l;
|
t = l;
|
||||||
l = r;
|
l = r;
|
||||||
r = t;
|
r = t;
|
||||||
}
|
}
|
||||||
/* should favour AX */
|
reg[D_DX]++; // for gopcode case OMUL
|
||||||
regalloc(&nod, l, nn);
|
regalloc(&nod, l, nn);
|
||||||
cgen(l, &nod);
|
cgen(l, &nod);
|
||||||
if(r->addable < INDEXED) {
|
if(r->addable < INDEXED) {
|
||||||
@ -422,6 +422,7 @@ cgen(Node *n, Node *nn)
|
|||||||
gopcode(OMUL, n->type, r, &nod); /* addressible */
|
gopcode(OMUL, n->type, r, &nod); /* addressible */
|
||||||
gmove(&nod, nn);
|
gmove(&nod, nn);
|
||||||
regfree(&nod);
|
regfree(&nod);
|
||||||
|
reg[D_DX]--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user