reorder1 - function first instead of last

SVN=122160
This commit is contained in:
Ken Thompson 2008-06-11 12:25:44 -07:00
parent a544938c26
commit 2bba3a610d
1 changed files with 8 additions and 10 deletions

View File

@ -1224,6 +1224,7 @@ convas(Node *n)
if(n->op != OAS) if(n->op != OAS)
fatal("convas: not as %O", n->op); fatal("convas: not as %O", n->op);
ullmancalc(n);
l = n->left; l = n->left;
r = n->right; r = n->right;
if(l == N || r == N) if(l == N || r == N)
@ -1321,7 +1322,7 @@ loop1:
if(c == 0 || t == 1) if(c == 0 || t == 1)
return n; return n;
if(c > 1) { if(c > 1) {
yyerror("reorder1: too many funcation calls evaluating parameters"); yyerror("reorder1: too many function calls evaluating parameters");
return n; return n;
} }
goto pass2; goto pass2;
@ -1337,21 +1338,18 @@ loop1:
pass2: pass2:
l = listfirst(&save, &n); l = listfirst(&save, &n);
f = N; // isolated function call r = N; // rest
r = N; // rest of them f = N; // fncall
loop2: loop2:
if(l == N) { if(l == N) {
if(r == N || f == N)
fatal("reorder1 not nil 1");
r = nod(OLIST, f, r); r = nod(OLIST, f, r);
return rev(r); r = rev(r);
return r;
} }
if(l->ullman >= UINF) { if(l->ullman >= UINF)
if(f != N)
fatal("reorder1 not nil 2");
f = l; f = l;
} else else
if(r == N) if(r == N)
r = l; r = l;
else else