diff options
Diffstat (limited to 'src/cmd/8g/ggen.c')
-rw-r--r-- | src/cmd/8g/ggen.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/cmd/8g/ggen.c b/src/cmd/8g/ggen.c index 108c493aa..6a4570199 100644 --- a/src/cmd/8g/ggen.c +++ b/src/cmd/8g/ggen.c @@ -4,6 +4,8 @@ #undef EXTERN #define EXTERN +#include <u.h> +#include <libc.h> #include "gg.h" #include "opt.h" @@ -26,10 +28,10 @@ markautoused(Prog* p) { for (; p; p = p->link) { if (p->from.type == D_AUTO && p->from.node) - p->from.node->used++; + p->from.node->used = 1; if (p->to.type == D_AUTO && p->to.node) - p->to.node->used++; + p->to.node->used = 1; } } @@ -429,7 +431,6 @@ hard: if(nr->ullman >= nl->ullman || nl->addable) { mgen(nr, &n2, N); nr = &n2; - nr = &n2; } else { tempname(&n2, nr->type); cgen(nr, &n2); @@ -483,8 +484,8 @@ void dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx) { int check; - Node n1, t1, t2, n4, nz; - Type *t; + Node n1, t1, t2, t3, t4, n4, nz; + Type *t, *t0; Prog *p1, *p2, *p3; // Have to be careful about handling @@ -496,6 +497,7 @@ dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx) // For int32 and int64, use explicit test. // Could use int64 hw for int32. t = nl->type; + t0 = t; check = 0; if(issigned[t->etype]) { check = 1; @@ -514,8 +516,18 @@ dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx) tempname(&t1, t); tempname(&t2, t); - cgen(nl, &t1); - cgen(nr, &t2); + if(t0 != t) { + tempname(&t3, t0); + tempname(&t4, t0); + cgen(nl, &t3); + cgen(nr, &t4); + // Convert. + gmove(&t3, &t1); + gmove(&t4, &t2); + } else { + cgen(nl, &t1); + cgen(nr, &t2); + } if(!samereg(ax, res) && !samereg(dx, res)) regalloc(&n1, t, res); |