Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving register assignment on x64 #792

Open
sorear opened this issue Oct 15, 2020 · 1 comment
Open

Improving register assignment on x64 #792

sorear opened this issue Oct 15, 2020 · 1 comment
Labels
code size enhancement low effort May still assume familiarity medium reward Easy to measure but may not be noticed by itself

Comments

@sorear
Copy link
Contributor

sorear commented Oct 15, 2020

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 sorear added enhancement code size low effort May still assume familiarity medium reward Easy to measure but may not be noticed by itself labels Oct 15, 2020
@tanyongkiam
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code size enhancement low effort May still assume familiarity medium reward Easy to measure but may not be noticed by itself
Projects
None yet
Development

No branches or pull requests

2 participants