-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: implement type-based alias analysis #70488
Comments
The reason CSE or other SSA optimizations didn’t eliminated the read of However, this can be done based on type aliasing rules. My reading of the rules (https://pkg.go.dev/unsafe#Pointer) is that no non-pointer type (like |
I implemented a patch that adds type-based alias analysis. Here it goes:
It kicks in and enables additional optimizations in a few spots in the standard library and a real-world program I tried (etcd). For example, it enables removal of However, this doesn't bring any tangible benefits to
@mundaym , @randall77 , it seems you are the primary authors of Andrey |
You'll want to read through https://go-review.googlesource.com/c/go/+/551381 first. I think possibly your ptr vs nonptr rule might work, but not the rest. |
Go version
go version devel go1.24-3ca78afb3b Mon Nov 18 04:56:52 2024 +0000 linux/arm64
Output of
go env
in your module/workspace:What did you do?
Test case:
Compiled with
go build -a -gcflags='-d ssa/all/dump=Foo' test.go
.What did you see happen?
Read of
*y
memory location and thus, the subsequent addition of a constant are not eliminated:What did you expect to see?
Read of
*y
eliminated; subsequent addition of two constant values (10
, which is the value of*y
and20
) folded.The text was updated successfully, but these errors were encountered: