Skip to content
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: ppc64le: sign extension issue in go 1.21rc2 #61297

Closed
eliben opened this issue Jul 11, 2023 · 4 comments
Closed

cmd/compile: ppc64le: sign extension issue in go 1.21rc2 #61297

eliben opened this issue Jul 11, 2023 · 4 comments
Assignees
Labels
arch-ppc64x compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@eliben
Copy link
Member

eliben commented Jul 11, 2023

Reported by Jan Mercl on golang-dev@

What version of Go are you using (go version)?

$ go version
go version go1.21rc2 linux/ppc64le

What operating system and processor architecture are you using (go env)?

$ uname -a
        Linux sqlite1 5.10.0-18-powerpc64le #1 SMP Debian 5.10.140-1 (2022-09-02) ppc64le GNU/Linux

What did you do?

Minimized reproducer at https://go.dev/play/p/ccmhhPkt0PI?v=gotip outputs

        55282
        55282

in the playground. Running the same code on linux/ppc64le:

        debian@sqlite1:~/tmp$ cat bug.go
        package main
       
        import (
                "fmt"
                "strconv"
        )
       
        func f(n int) int8 {
                return int8(n)
        }
       
        func main() {
                n, _ := strconv.Atoi("9")
                fmt.Println(int64(0xd7f2) & int64(f(-n)))
                fmt.Println(int64(0xd7f2) & int64(f(-9)))
        }

        debian@sqlite1:~/tmp$ go run bug.go
        242
        55282
@eliben
Copy link
Member Author

eliben commented Jul 11, 2023

cc @golang/ppc64

@pmur pmur self-assigned this Jul 11, 2023
@ianlancetaylor ianlancetaylor changed the title ppc64le: sign extension issue in go 1.21rc2 cmd/compile: ppc64le: sign extension issue in go 1.21rc2 Jul 11, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 11, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/508775 mentions this issue: cmd/compile: On PPC64, preserve sign extension when masking

@pmur
Copy link
Contributor

pmur commented Jul 12, 2023

@gopherbot please consider a backport for 1.20 and 1.19, this is a compiler bug without a workaround.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #61319 (for 1.19), #61320 (for 1.20).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@dmitshur dmitshur added this to the Go1.21 milestone Jul 14, 2023
@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 14, 2023
bradfitz pushed a commit to tailscale/go that referenced this issue Jul 15, 2023
(ANDCCconst [y] (MOV.*reg x)) should only be merged when zero
extending. Otherwise, sign bits are lost on negative values.

(ANDCCconst [0xFF] (MOVBreg x)) should be simplified to a zero
extension of x. Likewise for the MOVHreg variant.

Fixes golang#61297

Change-Id: I04e4fd7dc6a826e870681f37506620d48393698b
Reviewed-on: https://go-review.googlesource.com/c/go/+/508775
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-ppc64x compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants