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/asm: arm64 assembler rejects "MOVK $(33825<<48), R2" #52261

Closed
ericlagergren opened this issue Apr 10, 2022 · 2 comments
Closed

cmd/asm: arm64 assembler rejects "MOVK $(33825<<48), R2" #52261

ericlagergren opened this issue Apr 10, 2022 · 2 comments

Comments

@ericlagergren
Copy link
Contributor

ericlagergren commented Apr 10, 2022

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

$ go version
go version go1.18 darwin/arm64

Does this issue reproduce with the latest release?

This is the latest release.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/eric/gopath/bin"
GOCACHE="/Users/eric/Library/Caches/go-build"
GOENV="/Users/eric/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/eric/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/eric/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/eric/git/polyval/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2f/2_yz21b92h94_pvr2m00gzh80000gn/T/go-build2162191990=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Wrote an assembly program with MOVK $(33825<<48), R5.

(The instruction was taken from Clang generating movk x5, #33825, lsl #48.)

What did you expect to see?

It compile.

What did you see instead?

asm: requires uimm16
00096 (/Users/eric/git/polyval/polyval_arm64.s:451)	MOVK	$-8925852986471612416, R5
asm: assembly failed
@ericlagergren ericlagergren changed the title cmd/asm: rejects "MOVK $(33825<<48), R2" cmd/asm: arm64 assembler rejects "MOVK $(33825<<48), R2" Apr 10, 2022
@ericlagergren
Copy link
Contributor Author

ericlagergren commented Apr 10, 2022

The MOVK instruction was part of the hand-written sequence:

MOVD  $8456, R5
MOVK  $(4228<<16), R5
MOVK  $(2114<<32), R5
MOVK  $(33825<<48), R5

Interestingly, when I replace those instructions with

MOVD $0x8421084210842108, R5

the compiler actually emits the instruction that cmd/asm rejects:

$ go tool objdump -gnu -s ctmulAsm ./polyval.test
MOVD $8456, R5                       // mov x5, #0x2108
MOVK $(4228<<16), R5                 // movk x5, #0x1084, lsl #16
MOVK $(2114<<32), R5                 // movk x5, #0x842, lsl #32
MOVK $(33825<<48), R5                // movk x5, #0x8421, lsl #48

@gopherbot
Copy link

Change https://go.dev/cl/399455 mentions this issue: cmd/asm: fix MOVK when constant has high bit set

@golang golang locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants