]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm64: fix 32-bit BITCON test
authorCherry Zhang <cherryyz@google.com>
Fri, 8 May 2020 19:08:55 +0000 (15:08 -0400)
committerCherry Zhang <cherryyz@google.com>
Fri, 8 May 2020 20:57:01 +0000 (20:57 +0000)
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 <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/asm/internal/asm/testdata/arm64.s
src/cmd/internal/obj/arm64/asm7.go

index c0e2fb7e0e4df32c0d74f29851797350e963e00a..69267bfa63ad38b2a4736a234a8ca1d20ade41dd 100644 (file)
@@ -274,6 +274,9 @@ TEXT        foo(SB), DUPOK|NOSPLIT, $-8
        ADDW    $0x60060, R2                        // ADDW     $393312, R2                     // 4280011142804111
        CMPW    $0x60060, R2                        // CMPW     $393312, R2                     // 1b0c8052db00a0725f001b6b
 
+       // TODO: this could have better encoding
+       ANDW    $-1, R10 // 1b0080124a011b0a
+
        AND     $8, R0, RSP // 1f007d92
        ORR     $8, R0, RSP // 1f007db2
        EOR     $8, R0, RSP // 1f007dd2
index 9a1908a6551ff963a21d827072294db5223a59a1..7f5cba645a8b9e6dc18a64a7c45e29b667bd8551 100644 (file)
@@ -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
        }