cakeml icon indicating copy to clipboard operation
cakeml copied to clipboard

Improving register assignment on x64

Open sorear opened this issue 5 years ago • 1 comments

r12 and r13 do not need to be avoided, but they are less efficient to use under some circumstances: memory accesses relative to r12 with no (register) index, or accesses relative to r13 with an (immediate) displacement of zero, need one extra byte than comparable operations with a different base.

Currently r12 is the stack pointer (bad, since the stack generates lots of displacement-only accesses) and r13 is the stack limit/store pointer (fine, displacement 0 from r13 is beyond the stack top). I propose to swap r12 and r14.

sorear avatar Oct 15 '20 01:10 sorear

Probably a naive question: is this referring to the "r12" and "r13" as exposed by the encoder to CakeML?

I'm guessing not since I don't think r12/r13 have those special uses baked in (unless they are the last few registers used in stackLang)

If so, would it suffice to permute these three register mappings as you suggested? https://github.com/CakeML/cakeml/blob/master/compiler/backend/x64/x64_configScript.sml#L25

tanyongkiam avatar Dec 08 '20 13:12 tanyongkiam