Commit 2c09d699 authored by Russ Cox's avatar Russ Cox

cmd/gc: slightly better code generation

* Avoid treating CALL fn(SB) as justification for introducing
and tracking a registerized variable for fn(SB).

* Remove USED(n) after declaration and zeroing of n.
It was left over from when the compiler emitted more
aggressive set and not used errors, and it was keeping
the optimizer from removing a redundant zeroing of n
when n was a pointer or integer variable.

Update #597.

R=ken2
CC=golang-dev
https://golang.org/cl/7277048
parent d48cd5d1
...@@ -275,6 +275,10 @@ regopt(Prog *firstp) ...@@ -275,6 +275,10 @@ regopt(Prog *firstp)
} }
} }
// Avoid making variables for direct-called functions.
if(p->as == ABL && p->to.type == D_EXTERN)
continue;
/* /*
* left side always read * left side always read
*/ */
......
...@@ -252,6 +252,10 @@ regopt(Prog *firstp) ...@@ -252,6 +252,10 @@ regopt(Prog *firstp)
} }
} }
// Avoid making variables for direct-called functions.
if(p->as == ACALL && p->to.type == D_EXTERN)
continue;
// Addressing makes some registers used. // Addressing makes some registers used.
if(p->from.type >= D_INDIR) if(p->from.type >= D_INDIR)
r->use1.b[0] |= RtoB(p->from.type-D_INDIR); r->use1.b[0] |= RtoB(p->from.type-D_INDIR);
......
...@@ -222,6 +222,10 @@ regopt(Prog *firstp) ...@@ -222,6 +222,10 @@ regopt(Prog *firstp)
} }
} }
// Avoid making variables for direct-called functions.
if(p->as == ACALL && p->to.type == D_EXTERN)
continue;
// Addressing makes some registers used. // Addressing makes some registers used.
if(p->from.type >= D_INDIR) if(p->from.type >= D_INDIR)
r->use1.b[0] |= RtoB(p->from.type-D_INDIR); r->use1.b[0] |= RtoB(p->from.type-D_INDIR);
......
...@@ -735,8 +735,6 @@ cgen_as(Node *nl, Node *nr) ...@@ -735,8 +735,6 @@ cgen_as(Node *nl, Node *nr)
return; return;
} }
clearslim(nl); clearslim(nl);
if(nl->addable)
gused(nl);
return; return;
} }
......
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