Commit 57ad05db authored by Russ Cox's avatar Russ Cox

cmd/6g: use all 16 float registers, optimize float moves

Fixes #2446.

R=ken2
CC=golang-dev
https://golang.org/cl/6557044
parent b16c41be
...@@ -271,7 +271,7 @@ ginit(void) ...@@ -271,7 +271,7 @@ ginit(void)
reg[i] = 1; reg[i] = 1;
for(i=D_AX; i<=D_R15; i++) for(i=D_AX; i<=D_R15; i++)
reg[i] = 0; reg[i] = 0;
for(i=D_X0; i<=D_X7; i++) for(i=D_X0; i<=D_X15; i++)
reg[i] = 0; reg[i] = 0;
for(i=0; i<nelem(resvd); i++) for(i=0; i<nelem(resvd); i++)
...@@ -289,7 +289,7 @@ gclean(void) ...@@ -289,7 +289,7 @@ gclean(void)
for(i=D_AX; i<=D_R15; i++) for(i=D_AX; i<=D_R15; i++)
if(reg[i]) if(reg[i])
yyerror("reg %R left allocated\n", i); yyerror("reg %R left allocated\n", i);
for(i=D_X0; i<=D_X7; i++) for(i=D_X0; i<=D_X15; i++)
if(reg[i]) if(reg[i])
yyerror("reg %R left allocated\n", i); yyerror("reg %R left allocated\n", i);
} }
...@@ -359,10 +359,10 @@ regalloc(Node *n, Type *t, Node *o) ...@@ -359,10 +359,10 @@ regalloc(Node *n, Type *t, Node *o)
case TFLOAT64: case TFLOAT64:
if(o != N && o->op == OREGISTER) { if(o != N && o->op == OREGISTER) {
i = o->val.u.reg; i = o->val.u.reg;
if(i >= D_X0 && i <= D_X7) if(i >= D_X0 && i <= D_X15)
goto out; goto out;
} }
for(i=D_X0; i<=D_X7; i++) for(i=D_X0; i<=D_X15; i++)
if(reg[i] == 0) if(reg[i] == 0)
goto out; goto out;
fatal("out of floating registers"); fatal("out of floating registers");
......
...@@ -627,19 +627,34 @@ subprop(Reg *r0) ...@@ -627,19 +627,34 @@ subprop(Reg *r0)
Reg *r; Reg *r;
int t; int t;
if(debug['P'] && debug['v'])
print("subprop %P\n", r0->prog);
p = r0->prog; p = r0->prog;
v1 = &p->from; v1 = &p->from;
if(!regtyp(v1)) if(!regtyp(v1)) {
if(debug['P'] && debug['v'])
print("\tnot regtype %D; return 0\n", v1);
return 0; return 0;
}
v2 = &p->to; v2 = &p->to;
if(!regtyp(v2)) if(!regtyp(v2)) {
if(debug['P'] && debug['v'])
print("\tnot regtype %D; return 0\n", v2);
return 0; return 0;
}
for(r=uniqp(r0); r!=R; r=uniqp(r)) { for(r=uniqp(r0); r!=R; r=uniqp(r)) {
if(uniqs(r) == R) if(debug['P'] && debug['v'])
print("\t? %P\n", r->prog);
if(uniqs(r) == R) {
if(debug['P'] && debug['v'])
print("\tno unique successor\n");
break; break;
}
p = r->prog; p = r->prog;
switch(p->as) { switch(p->as) {
case ACALL: case ACALL:
if(debug['P'] && debug['v'])
print("\tfound %P; return 0\n", p);
return 0; return 0;
case AIMULL: case AIMULL:
...@@ -710,21 +725,33 @@ subprop(Reg *r0) ...@@ -710,21 +725,33 @@ subprop(Reg *r0)
case AMOVSB: case AMOVSB:
case AMOVSL: case AMOVSL:
case AMOVSQ: case AMOVSQ:
if(debug['P'] && debug['v'])
print("\tfound %P; return 0\n", p);
return 0; return 0;
case AMOVL: case AMOVL:
case AMOVQ: case AMOVQ:
case AMOVSS:
case AMOVSD:
if(p->to.type == v1->type) if(p->to.type == v1->type)
goto gotit; goto gotit;
break; break;
} }
if(copyau(&p->from, v2) || if(copyau(&p->from, v2) ||
copyau(&p->to, v2)) copyau(&p->to, v2)) {
if(debug['P'] && debug['v'])
print("\tcopyau %D failed\n", v2);
break; break;
}
if(copysub(&p->from, v1, v2, 0) || if(copysub(&p->from, v1, v2, 0) ||
copysub(&p->to, v1, v2, 0)) copysub(&p->to, v1, v2, 0)) {
if(debug['P'] && debug['v'])
print("\tcopysub failed\n");
break; break;
} }
}
if(debug['P'] && debug['v'])
print("\tran off end; return 0\n", p);
return 0; return 0;
gotit: gotit:
...@@ -769,6 +796,8 @@ copyprop(Reg *r0) ...@@ -769,6 +796,8 @@ copyprop(Reg *r0)
Adr *v1, *v2; Adr *v1, *v2;
Reg *r; Reg *r;
if(debug['P'] && debug['v'])
print("copyprop %P\n", r0->prog);
p = r0->prog; p = r0->prog;
v1 = &p->from; v1 = &p->from;
v2 = &p->to; v2 = &p->to;
...@@ -1180,14 +1209,23 @@ int ...@@ -1180,14 +1209,23 @@ int
copyau(Adr *a, Adr *v) copyau(Adr *a, Adr *v)
{ {
if(copyas(a, v)) if(copyas(a, v)) {
if(debug['P'] && debug['v'])
print("\tcopyau: copyas returned 1\n");
return 1; return 1;
}
if(regtyp(v)) { if(regtyp(v)) {
if(a->type-D_INDIR == v->type) if(a->type-D_INDIR == v->type) {
if(debug['P'] && debug['v'])
print("\tcopyau: found indir use - return 1\n");
return 1; return 1;
if(a->index == v->type) }
if(a->index == v->type) {
if(debug['P'] && debug['v'])
print("\tcopyau: found index use - return 1\n");
return 1; return 1;
} }
}
return 0; return 0;
} }
......
...@@ -1601,7 +1601,7 @@ int ...@@ -1601,7 +1601,7 @@ int
BtoF(int32 b) BtoF(int32 b)
{ {
b &= 0xFF0000L; b &= 0xFFFF0000L;
if(b == 0) if(b == 0)
return 0; return 0;
return bitno(b) - 16 + FREGMIN; return bitno(b) - 16 + FREGMIN;
......
...@@ -805,6 +805,14 @@ enum ...@@ -805,6 +805,14 @@ enum
D_X5, D_X5,
D_X6, D_X6,
D_X7, D_X7,
D_X8,
D_X9,
D_X10,
D_X11,
D_X12,
D_X13,
D_X14,
D_X15,
D_CS = 68, D_CS = 68,
D_SS, D_SS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment