From f1ac85c8d10e16fbc07e8b7ef93aa04bdc4c67e9 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Fri, 8 May 2020 15:08:55 -0400 Subject: cmd/internal/obj/arm64: fix 32-bit BITCON test The BITCON test, isbitcon, assumes 32-bit constants are expanded repeatedly, i.e. by copying the low 32 bits to high 32 bits, instead of zero extending. We already do such expansion in progedit. In con32class when classifying 32-bit constants, we should use the expanded constant, instead of zero-extending it. TODO: we could have better encoding for things like ANDW $-1, Rx. Fixes #38946. Change-Id: I37d0c95d744834419db5c897fd1f6c187595c926 Reviewed-on: https://go-review.googlesource.com/c/go/+/232984 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: David Chase --- src/cmd/internal/obj/arm64/asm7.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/cmd/internal/obj') diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go index 9a1908a655..7f5cba645a 100644 --- a/src/cmd/internal/obj/arm64/asm7.go +++ b/src/cmd/internal/obj/arm64/asm7.go @@ -1639,12 +1639,12 @@ func (c *ctxt7) con32class(a *obj.Addr) int { } if isaddcon(int64(v)) { if v <= 0xFFF { - if isbitcon(uint64(v)) { + if isbitcon(uint64(a.Offset)) { return C_ABCON0 } return C_ADDCON0 } - if isbitcon(uint64(v)) { + if isbitcon(uint64(a.Offset)) { return C_ABCON } if movcon(int64(v)) >= 0 { @@ -1658,7 +1658,7 @@ func (c *ctxt7) con32class(a *obj.Addr) int { t := movcon(int64(v)) if t >= 0 { - if isbitcon(uint64(v)) { + if isbitcon(uint64(a.Offset)) { return C_MBCON } return C_MOVCON @@ -1666,13 +1666,13 @@ func (c *ctxt7) con32class(a *obj.Addr) int { t = movcon(int64(^v)) if t >= 0 { - if isbitcon(uint64(v)) { + if isbitcon(uint64(a.Offset)) { return C_MBCON } return C_MOVCON } - if isbitcon(uint64(v)) { + if isbitcon(uint64(a.Offset)) { return C_BITCON } -- cgit v1.3