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: double assignment not optimized #31172

Closed
mariecurried opened this issue Mar 31, 2019 · 2 comments
Closed

cmd/compile: double assignment not optimized #31172

mariecurried opened this issue Mar 31, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@mariecurried
Copy link

What version of Go are you using (go version)?

$ go version
go version devel +576442b Fri Mar 29 23:05:45 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

I compiled the following code (simplified from a more complex program):

package test

var sink int

func aux() int {
    return 0
}

func test1() {
    sink = aux()
    sink = aux()
}

What did you expect to see?

I expected the double assignment to be compiled away, as in the code presented below:

package test

var sink int

func test1() {
    sink = 0
    sink = 0
}

What did you see instead?

Instead, the following code was generated:

        movq    $0, "".sink(SB)
        nop
        movq    $0, "".sink(SB)
        ret

Note: Before commit 69c2c56, the code snippets shown above behaved similarly.

@randall77
Copy link
Contributor

Yes, the inline marks prevent this optimization.
Removing unused inline marks would help.

@randall77 randall77 added this to the Unplanned milestone Mar 31, 2019
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 1, 2019
@gopherbot
Copy link

Change https://golang.org/cl/170445 mentions this issue: cmd/compile: get rid of unnecessary inline marks

@golang golang locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

4 participants