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: taking address of variables in chain breaks optimizations #33972

Open
mariecurried opened this issue Aug 30, 2019 · 2 comments
Open

cmd/compile: taking address of variables in chain breaks optimizations #33972

mariecurried opened this issue Aug 30, 2019 · 2 comments
Labels
NeedsInvestigation Performance
Milestone

Comments

@mariecurried
Copy link

@mariecurried mariecurried commented Aug 30, 2019

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

$ go version
go version devel +f484e96 Fri Aug 30 00:10:31 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What did you do?

I tested the behavior of the gc given a chain of address taking operations (I know these are pretty contrived examples):

  1. https://godbolt.org/z/3zXWuG
  2. https://godbolt.org/z/-8Qr0N
  3. https://godbolt.org/z/_msJAW
  4. https://godbolt.org/z/czEAhU

What did you expect to see?

I expected functions 1/2 to compile to a simple return of -1 and 3/4 to a return of x.

What did you see instead?

Instead, all the functions contain unnecessary instructions:

  1. Extra mov through the variable x
  2. Extra mov through the variable x and extra nil check
  3. Extra nil check
  4. Extra nil check
@av86743
Copy link

@av86743 av86743 commented Aug 30, 2019

What did you expect to see?

I expected all this functions to compile to a simple return of -1.

Even #3 and #4?

@mariecurried
Copy link
Author

@mariecurried mariecurried commented Aug 30, 2019

What did you expect to see?

I expected all this functions to compile to a simple return of -1.

Even #3 and #4?

Oops, fixed.

@randall77 randall77 added this to the Unplanned milestone Aug 30, 2019
@katiehockman katiehockman added the NeedsInvestigation label Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Performance
Projects
None yet
Development

No branches or pull requests

4 participants