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

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

Issue 6736068: code review 6736068: cmd/6g: fix crash in cgen_bmul. (Closed)
Patch Set: diff -r b1403cc90f4f https://go.googlecode.com/hg/ Created 12 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/ggen.c
===================================================================
--- a/src/cmd/6g/ggen.c
+++ b/src/cmd/6g/ggen.c
@@ -984,15 +984,10 @@
void
cgen_bmul(int op, Node *nl, Node *nr, Node *res)
{
- Node n1, n2, *tmp;
+ Node n1, n2, n1b, n2b, *tmp;
Type *t;
int a;
- // copy from byte to full registers
- t = types[TUINT64];
- if(issigned[nl->type->etype])
- t = types[TINT64];
-
// largest ullman on left.
if(nl->ullman < nr->ullman) {
tmp = nl;
@@ -1000,15 +995,25 @@
nr = tmp;
}
- regalloc(&n1, t, res);
- cgen(nl, &n1);
- regalloc(&n2, t, N);
- cgen(nr, &n2);
+ // generate operands in "8-bit" registers.
+ regalloc(&n1b, nl->type, res);
+ cgen(nl, &n1b);
+ regalloc(&n2b, nr->type, N);
+ cgen(nr, &n2b);
+
+ // perform full-width multiplication.
+ t = types[TUINT64];
+ if(issigned[nl->type->etype])
+ t = types[TINT64];
+ nodreg(&n1, t, n1b.val.u.reg);
+ nodreg(&n2, t, n2b.val.u.reg);
a = optoas(op, t);
gins(a, &n2, &n1);
- regfree(&n2);
+
+ // truncate.
gmove(&n1, res);
- regfree(&n1);
+ regfree(&n1b);
+ regfree(&n2b);
}
void
« 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