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

@mdempsky mdempsky commented Nov 30, 2017

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

This comment has been minimized.

Copy link
Contributor

@TocarIP TocarIP commented Dec 1, 2017

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

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 4, 2017

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

@gopherbot gopherbot closed this in 9916fee Feb 14, 2018
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.