summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2014-11-13 13:34:20 -0500
committerAustin Clements <austin@google.com>2014-11-13 13:34:20 -0500
commit71209f4e188b00dc368319aa74b285df00f3060c (patch)
treeb391fc76097379fa0001fa551f5df9f08dcfbef7
parent0dbc281709dfcda2314d25579ea09a2cdf8f31d4 (diff)
downloadgo-71209f4e188b00dc368319aa74b285df00f3060c.tar.gz
[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://codereview.appspot.com/174110043
-rw-r--r--src/cmd/6g/reg.c50
-rw-r--r--src/cmd/8g/reg.c48
2 files changed, 2 insertions, 96 deletions
diff --git a/src/cmd/6g/reg.c b/src/cmd/6g/reg.c
index afd3f1056..4ce2f4db0 100644
--- a/src/cmd/6g/reg.c
+++ b/src/cmd/6g/reg.c
@@ -1020,51 +1020,11 @@ 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;
}
diff --git a/src/cmd/8g/reg.c b/src/cmd/8g/reg.c
index 0fbe68482..79d60bed5 100644
--- a/src/cmd/8g/reg.c
+++ b/src/cmd/8g/reg.c
@@ -996,49 +996,11 @@ 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;
}