mirror of
https://github.com/golang/go
synced 2024-11-23 03:40:02 -07:00
cmd/5g: avoid temporaries in agen OINDEX
Most benchmarks are within the 3% margin of error. This code path is quite common in the fmt package. linux/arm, Freescale iMX.53 (cortex-a8) fmt: benchmark old ns/op new ns/op delta BenchmarkSprintfEmpty 925 785 -15.14% BenchmarkSprintfString 5050 5039 -0.22% BenchmarkSprintfInt 4425 4406 -0.43% BenchmarkSprintfIntInt 5802 5762 -0.69% BenchmarkSprintfPrefixedInt 7029 6541 -6.94% BenchmarkSprintfFloat 10278 10083 -1.90% BenchmarkManyArgs 18558 17606 -5.13% BenchmarkScanInts 15592690 15415360 -1.14% BenchmarkScanRecursiveInt 25155020 25050900 -0.41% R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6921056
This commit is contained in:
parent
4f79cef7f2
commit
3dcc63f750
@ -1007,22 +1007,21 @@ agenr(Node *n, Node *a, Node *res)
|
||||
|
||||
if(!debug['B'] && !n->bounded) {
|
||||
// check bounds
|
||||
regalloc(&n4, types[TUINT32], N);
|
||||
if(isconst(nl, CTSTR)) {
|
||||
nodconst(&n1, types[TUINT32], nl->val.u.sval->len);
|
||||
gmove(&n1, &n4);
|
||||
nodconst(&n4, types[TUINT32], nl->val.u.sval->len);
|
||||
} else if(isslice(nl->type) || nl->type->etype == TSTRING) {
|
||||
n1 = n3;
|
||||
n1.op = OINDREG;
|
||||
n1.type = types[tptr];
|
||||
n1.xoffset = Array_nel;
|
||||
regalloc(&n4, types[TUINT32], N);
|
||||
gmove(&n1, &n4);
|
||||
} else {
|
||||
nodconst(&n1, types[TUINT32], nl->type->bound);
|
||||
gmove(&n1, &n4);
|
||||
nodconst(&n4, types[TUINT32], nl->type->bound);
|
||||
}
|
||||
gcmp(optoas(OCMP, types[TUINT32]), &n2, &n4);
|
||||
regfree(&n4);
|
||||
if(n4.op == OREGISTER)
|
||||
regfree(&n4);
|
||||
p1 = gbranch(optoas(OLT, types[TUINT32]), T, +1);
|
||||
if(p2)
|
||||
patch(p2, pc);
|
||||
|
Loading…
Reference in New Issue
Block a user