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
marigonzes opened this issue Mar 31, 2019 · 2 comments

Comments

Projects
None yet
4 participants
@marigonzes
Copy link

commented Mar 31, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Mar 31, 2019

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

@randall77 randall77 added this to the Unplanned milestone Mar 31, 2019

@gopherbot

This comment has been minimized.

Copy link

commented Apr 2, 2019

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

@gopherbot gopherbot closed this in c46ebec Apr 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.