-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: extra unused instructions for LoweredNilCheck #17211
Comments
MOVB is an AMD64-ism -- PPC has no such instruction, so the assembler inserts the (unnecessary) sign extension. |
But why is the load instruction even there when it is loading it into a scratch register that is never used anywhere? If a NilCheck is supposed to be checking for a nil pointer, can't it just do a compare. |
Certainly on AMD64, it's fastest to do a useless load. A branch would require a place to branch to, etc. Is there a better way for PPC? |
The point for this NilCheck is that if it is a nil pointer, the load will trap. You are right that the extension is unnecessary. Using MOVD would not work as it will also trap on pointer that is not 8-aligned. |
CL https://golang.org/cl/29762 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +dcbbd31 Thu Sep 22 06:41:11 2016 +0000 linux/ppc64le
What operating system and processor architecture are you using (
go env
)?Ubuntu 16.04 ppc64le
Looking at generated code for code improvements.
This appears in many procedures and is never used (example found in runtime.c64hash):
Due to:
v26 = LoadReg <unsafe.Pointer> v8 : R3
v10 = LoweredNilCheck v26 v1
asm:
MOVB (R3), R31
With generated code:
11534: 00 00 e3 8b lbz r31,0(r3)
11538: 74 07 ff 7f extsb r31,r31
I'm not sure what it's purpose is. To avoid the extsb I believe I can just change this to a MOVD instead of a MOVB for the LoweredNilCheck, but r31 is never used in this function and the pointer for r3 is never dereferenced.
The text was updated successfully, but these errors were encountered: