1
0
mirror of https://github.com/golang/go synced 2024-10-03 11:11:22 -06:00

cmd/8g: don't create redundant temporaries in bgen.

Comparisons used to create temporaries for arguments
even if they were already variables or addressable.
Removing the extra ones reduces pressure on regopt.

benchmark                 old ns/op    new ns/op    delta
BenchmarkGobDecode         50787620     49908980   -1.73%
BenchmarkGobEncode         19870190     19473030   -2.00%
BenchmarkGzip            3214321000   3067929000   -4.55%
BenchmarkGunzip           496792800    465828600   -6.23%
BenchmarkJSONEncode       232524800    263864400  +13.48%
BenchmarkJSONDecode       622038400    506600600  -18.56%
BenchmarkMandelbrot200     23937310     45913060  +91.81%
BenchmarkParse             14364450     13997010   -2.56%
BenchmarkRevcomp         6919028000   6480009000   -6.35%
BenchmarkTemplate         594458800    539528200   -9.24%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            15.11        15.38    1.02x
BenchmarkGobEncode            38.63        39.42    1.02x
BenchmarkGzip                  6.04         6.33    1.05x
BenchmarkGunzip               39.06        41.66    1.07x
BenchmarkJSONEncode            8.35         7.35    0.88x
BenchmarkJSONDecode            3.12         3.83    1.23x
BenchmarkParse                 4.03         4.14    1.03x
BenchmarkRevcomp              36.73        39.22    1.07x
BenchmarkTemplate              3.26         3.60    1.10x

R=mtj, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6547064
This commit is contained in:
Rémy Oudompheng 2012-09-24 21:29:24 +02:00
parent 74a1a8ae5f
commit 14f3276c9d

View File

@ -1091,31 +1091,43 @@ bgen(Node *n, int true, int likely, Prog *to)
a = optoas(a, nr->type);
if(nr->ullman >= UINF) {
if(!nl->addable) {
tempname(&n1, nl->type);
tempname(&tmp, nr->type);
cgen(nl, &n1);
nl = &n1;
}
if(!nr->addable) {
tempname(&tmp, nr->type);
cgen(nr, &tmp);
nr = &tmp;
}
regalloc(&n2, nr->type, N);
cgen(&tmp, &n2);
cgen(nr, &n2);
goto cmp;
}
if(!nl->addable) {
tempname(&n1, nl->type);
cgen(nl, &n1);
nl = &n1;
}
if(smallintconst(nr)) {
gins(optoas(OCMP, nr->type), &n1, nr);
gins(optoas(OCMP, nr->type), nl, nr);
patch(gbranch(a, nr->type, likely), to);
break;
}
if(!nr->addable) {
tempname(&tmp, nr->type);
cgen(nr, &tmp);
nr = &tmp;
}
regalloc(&n2, nr->type, N);
gmove(&tmp, &n2);
gmove(nr, &n2);
cmp:
gins(optoas(OCMP, nr->type), &n1, &n2);
gins(optoas(OCMP, nr->type), nl, &n2);
patch(gbranch(a, nr->type, likely), to);
regfree(&n2);
break;