Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1399)

Unified Diff: src/cmd/6g/cgen.c

Issue 6622055: code review 6622055: cmd/6g: fix out of registers when chaining integer divi... (Closed)
Patch Set: diff -r 49b41500176a https://go.googlecode.com/hg/ Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/torture.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/6g/cgen.c
===================================================================
--- a/src/cmd/6g/cgen.c
+++ b/src/cmd/6g/cgen.c
@@ -402,7 +402,23 @@
a = optoas(n->op, nl->type);
goto abop;
}
- cgen_div(n->op, nl, nr, res);
+
+ if(nl->ullman >= nr->ullman) {
+ regalloc(&n1, nl->type, res);
+ cgen(nl, &n1);
+ cgen_div(n->op, &n1, nr, res);
+ regfree(&n1);
+ } else {
+ if(!smallintconst(nr)) {
+ regalloc(&n2, nr->type, res);
+ cgen(nr, &n2);
+ } else {
+ n2 = *nr;
+ }
+ cgen_div(n->op, nl, &n2, res);
+ if(n2.op != OLITERAL)
+ regfree(&n2);
+ }
break;
case OLSH:
« no previous file with comments | « no previous file | test/torture.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b