attempt to make register allocation deterministic

This commit is contained in:
Michael McLoughlin
2018-12-13 00:34:44 -08:00
parent 93b53377ac
commit c70c642ddb
2 changed files with 9 additions and 9 deletions

View File

@@ -3,16 +3,16 @@
// func Sum(xs []uint64) uint64 // func Sum(xs []uint64) uint64
TEXT ·Sum(SB),0,$0-32 TEXT ·Sum(SB),0,$0-32
MOVQ xs_base(FP), DX MOVQ xs_base(FP), AX
MOVQ xs_len+8(FP), AX MOVQ xs_len+8(FP), CX
XORQ CX, CX XORQ DX, DX
loop: loop:
CMPQ AX, $0x0 CMPQ CX, $0x0
JE done JE done
ADDQ (DX), CX ADDQ (AX), DX
ADDQ $0x8, DX ADDQ $0x8, AX
DECQ AX DECQ CX
JMP loop JMP loop
done: done:
MOVQ CX, ret+24(FP) MOVQ DX, ret+24(FP)
RET RET

View File

@@ -111,7 +111,7 @@ func (a *Allocator) mostrestricted() reg.Virtual {
n := int(math.MaxInt32) n := int(math.MaxInt32)
var v reg.Virtual var v reg.Virtual
for r, p := range a.possible { for r, p := range a.possible {
if len(p) < n { if len(p) < n || (len(p) == n && v != nil && r.VirtualID() < v.VirtualID()) {
n = len(p) n = len(p)
v = r v = r
} }