1
0
mirror of https://github.com/golang/go synced 2024-11-20 05:04:43 -07:00

cmd/5g, cmd/6g, cmd/8g: remove O(n) reset loop in copyprop

Simpler version of CL 13084043.

R=ken2
CC=golang-dev
https://golang.org/cl/13602045
This commit is contained in:
Russ Cox 2013-09-11 15:22:11 -04:00
parent a0bc379d46
commit 6d47de2f40
3 changed files with 21 additions and 15 deletions

View File

@ -47,6 +47,8 @@ static Flow* findpre(Flow *r, Adr *v);
static int copyau1(Prog *p, Adr *v);
static int isdconst(Addr *a);
static uint32 gactive;
// UNUSED
int shiftprop(Flow *r);
void constprop(Adr *c1, Adr *v1, Flow *r);
@ -63,6 +65,7 @@ peep(Prog *firstp)
g = flowstart(firstp, sizeof(Flow));
if(g == nil)
return;
gactive = 0;
loop1:
if(debug['P'] && debug['v'])
@ -360,15 +363,14 @@ copyprop(Graph *g, Flow *r0)
{
Prog *p;
Adr *v1, *v2;
Flow *r;
USED(g);
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;
gactive++;
return copy1(v1, v2, r0->s1, 0);
}
@ -378,12 +380,12 @@ copy1(Adr *v1, Adr *v2, Flow *r, int f)
int t;
Prog *p;
if(r->active) {
if(r->active == gactive) {
if(debug['P'])
print("act set; return 1\n");
return 1;
}
r->active = 1;
r->active = gactive;
if(debug['P'])
print("copy %D->%D f=%d\n", v1, v2, f);
for(; r != nil; r = r->s1) {

View File

@ -45,6 +45,8 @@ static int copyas(Adr*, Adr*);
static int copyau(Adr*, Adr*);
static int copysub(Adr*, Adr*, Adr*, int);
static uint32 gactive;
// do we need the carry bit
static int
needc(Prog *p)
@ -92,6 +94,7 @@ peep(Prog *firstp)
g = flowstart(firstp, sizeof(Flow));
if(g == nil)
return;
gactive = 0;
// byte, word arithmetic elimination.
elimshortmov(g);
@ -643,8 +646,8 @@ copyprop(Graph *g, Flow *r0)
{
Prog *p;
Adr *v1, *v2;
Flow *r;
USED(g);
if(debug['P'] && debug['v'])
print("copyprop %P\n", r0->prog);
p = r0->prog;
@ -652,8 +655,7 @@ 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;
gactive++;
return copy1(v1, v2, r0->s1, 0);
}
@ -663,12 +665,12 @@ copy1(Adr *v1, Adr *v2, Flow *r, int f)
int t;
Prog *p;
if(r->active) {
if(r->active == gactive) {
if(debug['P'])
print("act set; return 1\n");
return 1;
}
r->active = 1;
r->active = gactive;
if(debug['P'])
print("copy %D->%D f=%d\n", v1, v2, f);
for(; r != nil; r = r->s1) {

View File

@ -44,6 +44,8 @@ static int copyas(Adr*, Adr*);
static int copyau(Adr*, Adr*);
static int copysub(Adr*, Adr*, Adr*, int);
static uint32 gactive;
// do we need the carry bit
static int
needc(Prog *p)
@ -91,6 +93,7 @@ peep(Prog *firstp)
g = flowstart(firstp, sizeof(Flow));
if(g == nil)
return;
gactive = 0;
// byte, word arithmetic elimination.
elimshortmov(g);
@ -441,15 +444,14 @@ copyprop(Graph *g, Flow *r0)
{
Prog *p;
Adr *v1, *v2;
Flow *r;
USED(g);
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;
gactive++;
return copy1(v1, v2, r0->s1, 0);
}
@ -459,12 +461,12 @@ copy1(Adr *v1, Adr *v2, Flow *r, int f)
int t;
Prog *p;
if(r->active) {
if(r->active == gactive) {
if(debug['P'])
print("act set; return 1\n");
return 1;
}
r->active = 1;
r->active = gactive;
if(debug['P'])
print("copy %D->%D f=%d\n", v1, v2, f);
for(; r != nil; r = r->s1) {