shithub: riscv

Download patch

ref: c67d0c699f7b52da534f75d3620776997b1e8d52
parent: 28089ee035e8502ed03225c3850070c0c2882ae6
author: cinap_lenrek <[email protected]>
date: Sun Jan 8 12:41:10 EST 2017

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.

--- a/sys/src/cmd/6c/txt.c
+++ b/sys/src/cmd/6c/txt.c
@@ -343,9 +343,12 @@
 			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;