mirror of
https://github.com/golang/go
synced 2024-11-17 20:04:47 -07:00
cmd/5g, cmd/6g, cmd/8g: faster compilation
Replace linked list walk with memset. This reduces CPU time taken by 'go install -a std' by ~10%. Before: real user sys 0m23.561s 0m16.625s 0m5.848s 0m23.766s 0m16.624s 0m5.846s 0m23.742s 0m16.621s 0m5.868s after: 0m22.714s 0m14.858s 0m6.138s 0m22.644s 0m14.875s 0m6.120s 0m22.604s 0m14.854s 0m6.081s R=golang-dev, r CC=golang-dev https://golang.org/cl/13084043
This commit is contained in:
parent
c1dd7f4322
commit
06e686def6
@ -63,6 +63,8 @@ peep(Prog *firstp)
|
||||
g = flowstart(firstp, sizeof(Flow));
|
||||
if(g == nil)
|
||||
return;
|
||||
for(r=g->start, t=0; r!=nil; r=r->link, t++)
|
||||
r->active = t;
|
||||
|
||||
loop1:
|
||||
if(debug['P'] && debug['v'])
|
||||
@ -343,6 +345,9 @@ gotit:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uchar *active;
|
||||
static int nactive;
|
||||
|
||||
/*
|
||||
* The idea is to remove redundant copies.
|
||||
* v1->v2 F=0
|
||||
@ -360,15 +365,17 @@ copyprop(Graph *g, Flow *r0)
|
||||
{
|
||||
Prog *p;
|
||||
Adr *v1, *v2;
|
||||
Flow *r;
|
||||
|
||||
p = r0->prog;
|
||||
v1 = &p->from;
|
||||
v2 = &p->to;
|
||||
if(copyas(v1, v2))
|
||||
return 1;
|
||||
for(r=g->start; r!=nil; r=r->link)
|
||||
r->active = 0;
|
||||
if(nactive < g->num) {
|
||||
nactive = g->num;
|
||||
active = realloc(active, g->num);
|
||||
}
|
||||
memset(active, 0, g->num);
|
||||
return copy1(v1, v2, r0->s1, 0);
|
||||
}
|
||||
|
||||
@ -378,12 +385,12 @@ copy1(Adr *v1, Adr *v2, Flow *r, int f)
|
||||
int t;
|
||||
Prog *p;
|
||||
|
||||
if(r->active) {
|
||||
if(active[r->active]) {
|
||||
if(debug['P'])
|
||||
print("act set; return 1\n");
|
||||
return 1;
|
||||
}
|
||||
r->active = 1;
|
||||
active[r->active] = 1;
|
||||
if(debug['P'])
|
||||
print("copy %D->%D f=%d\n", v1, v2, f);
|
||||
for(; r != nil; r = r->s1) {
|
||||
|
@ -92,6 +92,8 @@ peep(Prog *firstp)
|
||||
g = flowstart(firstp, sizeof(Flow));
|
||||
if(g == nil)
|
||||
return;
|
||||
for(r=g->start, t=0; r!=nil; r=r->link, t++)
|
||||
r->active = t;
|
||||
|
||||
// byte, word arithmetic elimination.
|
||||
elimshortmov(g);
|
||||
@ -626,6 +628,9 @@ gotit:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uchar *active;
|
||||
static int nactive;
|
||||
|
||||
/*
|
||||
* The idea is to remove redundant copies.
|
||||
* v1->v2 F=0
|
||||
@ -643,7 +648,6 @@ copyprop(Graph *g, Flow *r0)
|
||||
{
|
||||
Prog *p;
|
||||
Adr *v1, *v2;
|
||||
Flow *r;
|
||||
|
||||
if(debug['P'] && debug['v'])
|
||||
print("copyprop %P\n", r0->prog);
|
||||
@ -652,8 +656,11 @@ copyprop(Graph *g, Flow *r0)
|
||||
v2 = &p->to;
|
||||
if(copyas(v1, v2))
|
||||
return 1;
|
||||
for(r=g->start; r!=nil; r=r->link)
|
||||
r->active = 0;
|
||||
if(nactive < g->num) {
|
||||
nactive = g->num;
|
||||
active = realloc(active, g->num);
|
||||
}
|
||||
memset(active, 0, g->num);
|
||||
return copy1(v1, v2, r0->s1, 0);
|
||||
}
|
||||
|
||||
@ -663,12 +670,12 @@ copy1(Adr *v1, Adr *v2, Flow *r, int f)
|
||||
int t;
|
||||
Prog *p;
|
||||
|
||||
if(r->active) {
|
||||
if(active[r->active]) {
|
||||
if(debug['P'])
|
||||
print("act set; return 1\n");
|
||||
return 1;
|
||||
}
|
||||
r->active = 1;
|
||||
active[r->active] = 1;
|
||||
if(debug['P'])
|
||||
print("copy %D->%D f=%d\n", v1, v2, f);
|
||||
for(; r != nil; r = r->s1) {
|
||||
|
@ -91,6 +91,8 @@ peep(Prog *firstp)
|
||||
g = flowstart(firstp, sizeof(Flow));
|
||||
if(g == nil)
|
||||
return;
|
||||
for(r=g->start, t=0; r!=nil; r=r->link, t++)
|
||||
r->active = t;
|
||||
|
||||
// byte, word arithmetic elimination.
|
||||
elimshortmov(g);
|
||||
@ -424,6 +426,9 @@ gotit:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uchar *active;
|
||||
static int nactive;
|
||||
|
||||
/*
|
||||
* The idea is to remove redundant copies.
|
||||
* v1->v2 F=0
|
||||
@ -441,15 +446,17 @@ copyprop(Graph *g, Flow *r0)
|
||||
{
|
||||
Prog *p;
|
||||
Adr *v1, *v2;
|
||||
Flow *r;
|
||||
|
||||
p = r0->prog;
|
||||
v1 = &p->from;
|
||||
v2 = &p->to;
|
||||
if(copyas(v1, v2))
|
||||
return 1;
|
||||
for(r=g->start; r!=nil; r=r->link)
|
||||
r->active = 0;
|
||||
if(nactive < g->num) {
|
||||
nactive = g->num;
|
||||
active = realloc(active, g->num);
|
||||
}
|
||||
memset(active, 0, g->num);
|
||||
return copy1(v1, v2, r0->s1, 0);
|
||||
}
|
||||
|
||||
@ -459,12 +466,12 @@ copy1(Adr *v1, Adr *v2, Flow *r, int f)
|
||||
int t;
|
||||
Prog *p;
|
||||
|
||||
if(r->active) {
|
||||
if(active[r->active]) {
|
||||
if(debug['P'])
|
||||
print("act set; return 1\n");
|
||||
return 1;
|
||||
}
|
||||
r->active = 1;
|
||||
active[r->active] = 1;
|
||||
if(debug['P'])
|
||||
print("copy %D->%D f=%d\n", v1, v2, f);
|
||||
for(; r != nil; r = r->s1) {
|
||||
|
Loading…
Reference in New Issue
Block a user