cmd/compile: optimize conditional pointer assignment #34020
Labels
Milestone
Comments
Why would you write code like that? I mean, yeah, it could be compiled more efficiently... but optimizations generally 1) increase the complexity of the compiler's code 2) have the potential to slow down the compiler; so in general it's only worth to optimize reasonable code patterns that could appear in real-world code. Is this the case? |
You are probably right, but I found this while looking at an example published in Slack (https://godbolt.org/z/kofqr2). After playing around with the code, I ended up with the above function and opened this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
I compiled the following function (https://godbolt.org/z/rRkMVJ):
What did you expect to see?
I expected that the generated instructions would be similar to https://godbolt.org/z/q0k3NT
What did you see instead?
Instead, there are
MOV
instructions to temporary stack variables and there is no use of theCMOV
instruction.The text was updated successfully, but these errors were encountered: