mirror of https://github.com/golang/go.git
[dev.power64] 6g,8g: remove unnecessary and incorrect reg use scanning
Previously, the 6g and 8g registerizers scanned for used registers beyond the end of a region being considered for registerization. This ancient artifact was copied from the C compilers, where it was probably necessary to track implicitly used registers. In the Go compilers it's harmless (because it can only over-restrict the set of available registers), but no longer necessary because the Go compilers correctly track register use/set information. The consequences of this extra scan were (at least) that 1) we would not consider allocating the AX register if there was a deferproc call in the future because deferproc uses AX as a return register, so we see the use of AX, but don't track that AX is set by the CALL, and 2) we could not consider allocating the DX register if there was a MUL in the future because MUL implicitly sets DX and (thanks to an abuse of copyu in this code) we would also consider DX used. This commit fixes these problems by nuking this code. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/174110043
This commit is contained in:
parent
8c060d9392
commit
c3dadb3d19
|
|
@ -1019,52 +1019,12 @@ paint1(Reg *r, int bn)
|
|||
}
|
||||
}
|
||||
|
||||
uint32
|
||||
regset(Reg *r, uint32 bb)
|
||||
{
|
||||
uint32 b, set;
|
||||
Adr v;
|
||||
int c;
|
||||
|
||||
set = 0;
|
||||
v = zprog.from;
|
||||
while(b = bb & ~(bb-1)) {
|
||||
v.type = b & 0xFFFF? BtoR(b): BtoF(b);
|
||||
if(v.type == 0)
|
||||
fatal("zero v.type for %#ux", b);
|
||||
c = copyu(r->f.prog, &v, nil);
|
||||
if(c == 3)
|
||||
set |= b;
|
||||
bb &= ~b;
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
uint32
|
||||
reguse(Reg *r, uint32 bb)
|
||||
{
|
||||
uint32 b, set;
|
||||
Adr v;
|
||||
int c;
|
||||
|
||||
set = 0;
|
||||
v = zprog.from;
|
||||
while(b = bb & ~(bb-1)) {
|
||||
v.type = b & 0xFFFF? BtoR(b): BtoF(b);
|
||||
c = copyu(r->f.prog, &v, nil);
|
||||
if(c == 1 || c == 2 || c == 4)
|
||||
set |= b;
|
||||
bb &= ~b;
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
uint32
|
||||
paint2(Reg *r, int bn)
|
||||
{
|
||||
Reg *r1;
|
||||
int z;
|
||||
uint64 bb, vreg, x;
|
||||
uint64 bb, vreg;
|
||||
|
||||
z = bn/64;
|
||||
bb = 1LL << (bn%64);
|
||||
|
|
@ -1108,14 +1068,6 @@ paint2(Reg *r, int bn)
|
|||
break;
|
||||
}
|
||||
|
||||
bb = vreg;
|
||||
for(; r; r=(Reg*)r->f.s1) {
|
||||
x = r->regu & ~bb;
|
||||
if(x) {
|
||||
vreg |= reguse(r, x);
|
||||
bb |= regset(r, x);
|
||||
}
|
||||
}
|
||||
return vreg;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -995,50 +995,12 @@ paint1(Reg *r, int bn)
|
|||
}
|
||||
}
|
||||
|
||||
uint32
|
||||
regset(Reg *r, uint32 bb)
|
||||
{
|
||||
uint32 b, set;
|
||||
Adr v;
|
||||
int c;
|
||||
|
||||
set = 0;
|
||||
v = zprog.from;
|
||||
while(b = bb & ~(bb-1)) {
|
||||
v.type = b & 0xFF ? BtoR(b): BtoF(b);
|
||||
c = copyu(r->f.prog, &v, nil);
|
||||
if(c == 3)
|
||||
set |= b;
|
||||
bb &= ~b;
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
uint32
|
||||
reguse(Reg *r, uint32 bb)
|
||||
{
|
||||
uint32 b, set;
|
||||
Adr v;
|
||||
int c;
|
||||
|
||||
set = 0;
|
||||
v = zprog.from;
|
||||
while(b = bb & ~(bb-1)) {
|
||||
v.type = b & 0xFF ? BtoR(b): BtoF(b);
|
||||
c = copyu(r->f.prog, &v, nil);
|
||||
if(c == 1 || c == 2 || c == 4)
|
||||
set |= b;
|
||||
bb &= ~b;
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
uint32
|
||||
paint2(Reg *r, int bn)
|
||||
{
|
||||
Reg *r1;
|
||||
int z;
|
||||
uint64 bb, vreg, x;
|
||||
uint64 bb, vreg;
|
||||
|
||||
z = bn/64;
|
||||
bb = 1LL << (bn%64);
|
||||
|
|
@ -1082,14 +1044,6 @@ paint2(Reg *r, int bn)
|
|||
break;
|
||||
}
|
||||
|
||||
bb = vreg;
|
||||
for(; r; r=(Reg*)r->f.s1) {
|
||||
x = r->regu & ~bb;
|
||||
if(x) {
|
||||
vreg |= reguse(r, x);
|
||||
bb |= regset(r, x);
|
||||
}
|
||||
}
|
||||
return vreg;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue