summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-04-19 01:25:35 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-04-19 01:25:35 +0200
commite6634fbd0c3e091d6db26c4290d6b31e1e7a36e7 (patch)
treefd2299060f79b518ea9207e0497cc96c438b799a
parent380adf8b485ce93aa42ad0d414718c3ad4918176 (diff)
downloadplan9front-e6634fbd0c3e091d6db26c4290d6b31e1e7a36e7.tar.xz
6c: conserve registers for floating point operations
for floating point operations, reuse the return register on the right hand side if it has higher complex number than the left hand side to conserve registers. this makes the following code compile, that was previously run out of floating point register: float f(float r[15]) { return (r[0] + (r[1] * (r[2] + r[3] * (r[4] + r[5] * (r[6] + r[7] * (r[8] + r[9] * (r[10] + r[11] * (r[12] + r[13] * r[14])))))))); } the downside is that this produces extra move operations.
-rw-r--r--sys/src/cmd/6c/cgen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/src/cmd/6c/cgen.c b/sys/src/cmd/6c/cgen.c
index 3a5de9e21..d86eed225 100644
--- a/sys/src/cmd/6c/cgen.c
+++ b/sys/src/cmd/6c/cgen.c
@@ -824,9 +824,9 @@ cgen(Node *n, Node *nn)
gopcode(o, n->type, r, &nod);
} else {
/* TO DO: could do better with r->addable >= INDEXED */
- regalloc(&nod1, r, Z);
+ regalloc(&nod1, r, nn);
cgen(r, &nod1);
- regalloc(&nod, l, nn);
+ regalloc(&nod, l, Z);
cgen(l, &nod);
gopcode(o, n->type, &nod1, &nod);
regfree(&nod1);