-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: deadstores and nilchecks solvable after memory to ssa renames are not handled #69174
Comments
cc @golang/compiler @randall77 |
This happens without inlining: https://go.godbolt.org/z/v58b47zf3 I know why it fails, there is a systemic tradeoff in most of the compiler only operating on SSA values, when you store things in memory ( Solving this for all possible cases is impossible, and getting right often is extremely costy both in term of compilation time and compiler code complexity which is a tradeoff the go compiler usually do not accept. I have an idea on how to cheaply improve this extremely naive example but this wont solve much more cases. |
Well I was only able to improve the situation slightly:
I removed the in the way nilchecks, which removes one more load, however then the dead stores become in the way and I don't know of a cheap way to run theses during late opt. |
Change https://go.dev/cl/609995 mentions this issue: |
Go version
go version devel go1.24-7fcd4a7 Mon Aug 19 23:36:23 2024 +0000 linux/amd64
What did you do?
I was reading https://www.dolthub.com/blog/2024-08-23-the-4-chan-go-programmer and there was a piece of code that caught my attention (keep in mind that it is a contrived example, but could reveal a bigger problem). So I decided to check the generated assembly (https://go.godbolt.org/z/oxqbPnPxn).
What did you see happen?
In some of the functions there were redundant instructions (marked with
; REDUNDANT
).setInt4
is compiled to:setInt3
is compiled to:setInt2
is compiled to:setInt1
is compiled to:What did you expect to see?
I expected to see no redundant instructions.
The text was updated successfully, but these errors were encountered: