-
Notifications
You must be signed in to change notification settings - Fork 18k
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: miscompilation of zero extension on ppc64le #29943
Comments
According to a git bisect, the error was introduced at https://golang.org/cl/129875 (8dbd9af). |
CC @martisch |
CC @dr2chase |
CC @rasky |
The comment at https://go-review.googlesource.com/c/go/+/129875/8/src/cmd/compile/internal/ssa/gen/PPC64.rules#903 says
I think this is exactly the reason of this failure (yah, the "future" has come). |
Before lower,
Note that v29 has a 64-bit type. After lower,
Note that v10, MOVWZ is a 32-bit to 64-bit zero extension, but has type int32. And the rule folds v10 to v29, which folds into the CMP, v28. After regalloc,
v10 is spilled (because of the call to g), but the spill and reload are just 32-bit load/store. |
On all architectures but PPC64, Trunc64to32 is a no-op. Why it is not on PPC64?
|
That was an old comment and I don't know where it originated.
The rules beneath the comment are not mixing zero truncates with signed
loads as this case does.
I think more likely it has to do with the Trunc rules immediately above
that comment, I think there was a concern about the change I made there.
…On Fri, Jan 25, 2019 at 4:09 PM cherrymui ***@***.***> wrote:
The comment at
https://go-review.googlesource.com/c/go/+/129875/8/src/cmd/compile/internal/ssa/gen/PPC64.rules#903
says
// Note that MOV??reg returns a 64-bit int, x is not necessarily that wide
// This may interact with other patterns in the future. (Compare with arm64)
I think this is exactly the reason of this failure (yah, the "future" has
come).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29943 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AI_wjDe9X4LqVj3LBCsiORxNViN3cWw3ks5vG4CYgaJpZM4aTsXs>
.
|
I don't understand these rules (but I'm not familiar with this code). Truncating a 64-bit value to a 32-bit value is an operation that is independent of whether the type of the operand is signed. |
It is not the rule immediately followed the comment. It is this
The outer MOVWZ is ZeroExt32to64, the inner one is Trunc64to32. The reason is same: |
On ARM64, MIPS64, and S390X, it is |
What is our path forward here so that we can unblock the 1.12 release? Should we roll back this CL, or part of it? |
Change https://golang.org/cl/159760 mentions this issue: |
This file is miscompiled on ppc64le:
On amd64 with tip, or on ppc64le with Go 1.11.5, this program runs without error. On ppc64le GNU/Linux with tip, the program panics:
Using objdump to look at the executable, I see this:
The variable
i32
is stored at48(r1)
. At PC62200
, the value is loaded, but it is loaded with anlwa
instruction, which sign extends the value. This corresponds to the Go expressionuint64(uint32(i32))
, which should zero extend the value, presumably usinglwz
.This is a miscompilation of valid code so it is a release blocker for 1.12.
CC @randall77 @laboger
The text was updated successfully, but these errors were encountered: