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: constants of same underlying type are not merged #15043
Comments
Yep. We use the frontend's notion of the equality, which takes into account named types, etc. I think there's an item in the ssa todo file to use a looser notion of equality; good to have it as an issue too. cc @mdempsky |
The particular example in this bug will be fixed by https://go-review.googlesource.com/c/21008 |
I might be mis-remembering, but I thought that @dr2chase had implemented a structural type equality, but didn't commit it. I think it would be fairly easy and safe to modify zcse to handle cases like this without much effort. |
CL https://golang.org/cl/21483 mentions this issue. |
They have different semantics. Equal is stricter and is designed for the front-end. Compare is looser and cheaper and is designed for the back-end. To avoid possible regression, remove Equal from ssa.Type. Updates golang#15043 Change-Id: Ie23ce75ff6b4d01b7982e0a89e6f81b5d099d8d6 Reviewed-on: https://go-review.googlesource.com/21483 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
This looks fixed now. |
Please answer these questions before submitting your issue. Thanks!
go version
)?go version devel +d8f1f8d Wed Mar 30 22:27:13 2016 +0000 linux/amd64
go env
)?linux amd64
Compiled the following program
One bounds check.
4 bounds checks. The constants foo(3), bar(3), spam(3), eggs(3) are not merged by the zcse pass nor by the constants cache. However, most rewrite rules ignore the type and only use op.
@josharian @tzneal
The text was updated successfully, but these errors were encountered: