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

cmd/compile: stack offsets should not need spilling #22947

Closed
mdempsky opened this issue Nov 30, 2017 · 2 comments
Closed

cmd/compile: stack offsets should not need spilling #22947

mdempsky opened this issue Nov 30, 2017 · 2 comments
Milestone

Comments

@mdempsky
Copy link
Member

Compiling the function below currently produces a register spill:

package p

type T [100]int

func f(p *T) {
    if g() {
            h(0, *p)
    } else {
            g()
            h(1, *p)
    }
}

func g() bool
func h(int, T)

This is because h(1, *p) is compiled to OINDREGSP(8) = *p, which is represented in SSA as Move(OffPtr(8, SP), p).

OffPtr(8, SP) is trivially rematerialized on x86 with LEA $8(SP), but we're currently lowering OffPtr to ADDQconst, which is marked as non-rematerializeable because it clobbers flags (unlike LEAQ).

Distilled from #22558.

/cc @randall77

@mdempsky mdempsky added this to the Go1.11 milestone Nov 30, 2017
@TocarIP
Copy link
Contributor

TocarIP commented Dec 1, 2017

We can probably add a rule that transforms (ADDQconst (SP)) into LEAQ

@gopherbot
Copy link

Change https://golang.org/cl/81815 mentions this issue: cmd/compile/internal/ssa: don't spill register offsets on amd64

@golang golang locked and limited conversation to collaborators Feb 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants