From c67d0c699f7b52da534f75d3620776997b1e8d52 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 8 Jan 2017 17:41:10 +0100 Subject: 6c: reverse register allocation order to avoid having to spill AX,DX and CX allocating AX,CX,DX last improves 64-bit multiplication-add chains like a*b + c*d as the multiplication does not need to save and restore AX and DX registers in most cases. reserving CX for shifts also helps. --- sys/src/cmd/6c/txt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/src/cmd/6c/txt.c b/sys/src/cmd/6c/txt.c index 861cdfde4..82045c168 100644 --- a/sys/src/cmd/6c/txt.c +++ b/sys/src/cmd/6c/txt.c @@ -343,9 +343,12 @@ regalloc(Node *n, Node *tn, Node *o) if(i >= D_AX && i <= D_R15) goto out; } - for(i=D_AX; i<=D_R15; i++) + for(i=D_AX; i<=D_R15; i++){ + i ^= 7; if(reg[i] == 0 && !resvreg[i]) goto out; + i ^= 7; + } diag(tn, "out of fixed registers"); goto err; -- cgit v1.2.3