-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd: incorrect assembly of CMP Rn,$0 on ppc64le/ppc64 #14532
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
Comments
On PPC r0 always contains 0 by definition (that is, it is not a real register). I think this is working as intended. |
Yeah, R0 is always 0 in the Go ABI. |
And what happens when Go code calls C code built by gcc where it is not always 0? Does it reinitialize it when it returns? |
On 27/02/2016 8:44 am, "laboger" notifications@github.com wrote:
Yes. |
Thanks for the responses. |
ianlancetaylor wrote:
To be pedantic, r0 is a real register and can contain non-zero data. In fact, we use r0 as a scratch register in GCC all the time, as well as when we save/restore the link register in the prologue/epilogue. That said, there are instructions where the contents of r0 are ignored and the value zero is used instead. For example, the base register in load and store instructions and addi and addis, etc. but only if r0 is the RA operand. If r0 isn't reset whenever r0 is used like calling non GO routines (eg, C), or whenever making syscalls (r0 holds the syscall number), then you can't guarantee that r0 is zero. |
Yes. R0 is a real register on ppc64, but Go always keeps it zero.
|
Please answer these questions before submitting your issue. Thanks!
go version
)?go 1.6
go env
)?linux ppc64le
I'm working on updating some asm file changes to improve performance on ppc64le. I see many
files that contain CMP Ra,$0 that generate the wrong ppc64 assembler. I'm guessing that the contents of r0 is usually 0 and that is allowing these to work by luck.
For an ASM like this:
CMP R3,$0
the code should be
cmpdi r3,0
cmpd r3,r0
This is from an objdump:
TEXT runtime·memeqbody(SB),NOSPLIT,$0-0
......
CMPU R5,$0
757ac: 40 00 25 7c cmpld r5,r0
However if the value is not 0, then it assembles correctly
757b4: 20 00 25 2c cmpdi r5,32
The text was updated successfully, but these errors were encountered: