summaryrefslogtreecommitdiff
path: root/src/cmd/5g/cgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/5g/cgen.c')
-rw-r--r--src/cmd/5g/cgen.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/cmd/5g/cgen.c b/src/cmd/5g/cgen.c
index 032409bae..4e5f7ebcd 100644
--- a/src/cmd/5g/cgen.c
+++ b/src/cmd/5g/cgen.c
@@ -43,6 +43,8 @@ cgen(Node *n, Node *res)
}
if(isfat(n->type)) {
+ if(n->type->width < 0)
+ fatal("forgot to compute width for %T", n->type);
sgen(n, res, n->type->width);
goto ret;
}
@@ -960,7 +962,7 @@ bgen(Node *n, int true, Prog *to)
}
// make simplest on right
- if(nl->op == OLITERAL || nl->ullman < nr->ullman) {
+ if(nl->op == OLITERAL || (nl->ullman < UINF && nl->ullman < nr->ullman)) {
a = brrev(a);
r = nl;
nl = nr;
@@ -1071,18 +1073,18 @@ bgen(Node *n, int true, Prog *to)
a = optoas(a, nr->type);
if(nr->ullman >= UINF) {
- regalloc(&n1, nr->type, N);
- cgen(nr, &n1);
+ regalloc(&n1, nl->type, N);
+ cgen(nl, &n1);
- tempname(&tmp, nr->type);
+ tempname(&tmp, nl->type);
gmove(&n1, &tmp);
regfree(&n1);
- regalloc(&n1, nl->type, N);
- cgen(nl, &n1);
-
regalloc(&n2, nr->type, N);
- cgen(&tmp, &n2);
+ cgen(nr, &n2);
+
+ regalloc(&n1, nl->type, N);
+ cgen(&tmp, &n1);
gcmp(optoas(OCMP, nr->type), &n1, &n2);
patch(gbranch(a, nr->type), to);