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/internal/obj/arm64: when the immediate is MOVCON/BITCON type, assembler handles "cmp/cmn $immediate, RSP" instruction incorrectly. #25557

Closed
zhangfannie opened this issue May 25, 2018 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@zhangfannie
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

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

go version devel +87a18c6 Tue May 22 02:58:04 2018 +0000 linux/arm64

Does this issue reproduce with the latest release?

yes

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

GOARCH="arm64"
GOBIN=""
GOCACHE="/home/fanzha02/.cache/go-build"
GOEXE=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fanzha02/go"
GORACE=""
GOROOT="/mnt/share/homes/fanzha02/RefineAsm/golang"
GOTMPDIR=""
GOTOOLDIR="/mnt/share/homes/fanzha02/RefineAsm/golang/pkg/tool/linux_arm64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build672309942=/tmp/go-build -gno-record-gcc-switches"

What did you do?

check assembler assembly instruction "CMPW $0x22220000, RSP", the instruction is encoded as two binary 5b44a4d2 ff031b6b. binary 5b44a4d2 is decoded as MOVD $0x2222000, R27, binary ff031b6b is decoded as CMPW R27, ZR.

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

CMPW $0x2222000, RSP is assembled as MOVD $0x22220000, R27, CMPW R27, RSP(CMP (extended register))

What did you see instead?

CMPW $0x2222000, RSP is assembled as MOVD $0x22220000, R27, CMPW R27, ZR(CMP (shifted register))

@zhangfannie zhangfannie changed the title cmd/internal/obj/arm64: when the immediate is MOVCON type, assembler handles cmp/cmn (immediate) instruction incorrectly. cmd/internal/obj/arm64: when the immediate is MOVCON/BITCON type, assembler handles "cmp/cmn $immediate, RSP" instruction incorrectly. May 25, 2018
@andybons
Copy link
Member

@randall77

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 25, 2018
@andybons andybons added this to the Unplanned milestone May 25, 2018
@benshi001
Copy link
Member

benshi001 commented May 26, 2018

There is one more error with optab 62,

  1. "AND $0x22220000, R2, RSP" is encoded to 5b44a4d25f601b00, which should be a report of "illegal combination".

first, 5f601b00 is not a legal aarch64 instruction

second, "AND Reg, Reg, Reg" does not accept RSP as source or destination.

According to arm64's architecture reference manual, using RSP as destination in AND is only legal in "AND C_BITCON, Reg, RSP".

The attempt to emulate "AND C_MOVCON, Reg, RSP" by combination of
"MOV C_MOVCON, Rtmp"
"AND Rtmp, RSP, RSP" is illegal

@benshi001 benshi001 self-assigned this May 26, 2018
@benshi001 benshi001 modified the milestones: Unplanned, Go1.11 May 26, 2018
@benshi001 benshi001 added the NeedsFix The path to resolution is known, but the work has not been done. label May 26, 2018
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 26, 2018
@gopherbot
Copy link

Change https://golang.org/cl/114796 mentions this issue: cmd/internal/arm64: fix two issues in the assembler

@golang golang locked and limited conversation to collaborators Jun 1, 2019
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