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: incorrect assembly output for 386 #16203

Closed
ericlagergren opened this issue Jun 29, 2016 · 5 comments
Closed

cmd/compile: incorrect assembly output for 386 #16203

ericlagergren opened this issue Jun 29, 2016 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ericlagergren
Copy link
Contributor

ericlagergren commented Jun 29, 2016

Please answer these questions before submitting your issue. Thanks!

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

1.6.2 (on my laptop and Vagrant; unsure about play.golang.org)

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

Vagrant:

GOARCH="386"
GOBIN=""
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/vagrant/gopath"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_386"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

Laptop:

GOARCH="amd64"
GOBIN="/home/eric/gopath/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eric/gopath"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

I ran this (https://play.golang.org/p/HNidlIeDdb) in three separate environments:

My laptop
Vagrant
play.golang.org

  1. What did you expect to see?

All three of them return 1 when +1 is passed.

  1. What did you see instead?
  • play.golang.org returned 1
  • my laptop returned 1
  • vagrant returned 0

I spoke with Tv` in #go-nuts to make sure I wasn't, well, going nuts and he came up with this repro: https://play.golang.org/p/VgyYHJAYu2

Here's the generated assembly from Vagrant:
objdump: https://gist.github.com/EricLagergren/8a53922a0f58dfef8d62710b062b637a
gcflags -S: https://gist.github.com/EricLagergren/93392d4977c63c74b0039c122b3d9b0b

Here's proof I didn't just goof up the Vagrant code 😀 : https://gist.github.com/EricLagergren/af4215805a0d88e426fde0c55696df3c

@ericlagergren ericlagergren changed the title cmd/compile: incorrect assembly cmd/compile: incorrect assembly output for 386 Jun 29, 2016
@randall77
Copy link
Contributor

Looks like a bug in the 386 backend. (vagrant is 32-bit Go, the others are 64-bit Go).
Minimal repro:

package main

func main() {
    println(s(1))
}

//go:noinline
func s(x int64) int64 {
    return (-x) >> 63
}

@randall77 randall77 added this to the Go1.7Maybe milestone Jun 29, 2016
@randall77 randall77 added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 29, 2016
@ericlagergren
Copy link
Contributor Author

Aside: Is the playground not 32 bits? Its int caps out at 1 << 32 - 1

ericlagergren added a commit to ericlagergren/decimal that referenced this issue Jun 29, 2016
@randall77
Copy link
Contributor

@ericlagergren , good question. I think maybe because the playground is amd64p32, or because it runs with -N. Not sure what its current state is.

@josharian
Copy link
Contributor

Not a regression from 1.6, so while this is unfortunate, I think it should wait for 1.8 (where SSA will very likely fix it for free).

@josharian josharian modified the milestones: Go1.8, Go1.7Maybe Jun 29, 2016
@randall77
Copy link
Contributor

Yes, this is fixed with the 386 SSA backend. Should be in master momentarily.

@golang golang locked and limited conversation to collaborators Aug 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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