]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[release-branch.go1.22] cmd/internal/obj/ppc64: fix incorrect int to int64 conversion...
authorPaul E. Murphy <murp@ibm.com>
Mon, 22 Apr 2024 21:16:30 +0000 (16:16 -0500)
committerJoedian Reid <joedian@google.com>
Fri, 26 Apr 2024 16:29:36 +0000 (16:29 +0000)
A type conversion from int to int64 was done in the wrong place causing
some MOVD $const, Rx operations to be incorrectly transformed on 32 bit
hosts cross-compiling for ppc64x.

Fixes #67018

Change-Id: I023ba267a8dac6d6bd22f8146c0d9d2d473bc5c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/580796
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Joedian Reid <joedian@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/581455

src/cmd/asm/internal/asm/testdata/ppc64.s
src/cmd/internal/obj/ppc64/obj9.go

index 01052b49e7e65de915c90729be60d4fa09266f1f..f84bc1491439a7ec6f26118950a1e0944e33a28f 100644 (file)
@@ -52,6 +52,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
        // Hex constant 0xFFFFFFFE00000001
        MOVD $-8589934591, R5           // 38a0ffff or 0602000038a00001
 
+       // For #66955. Verify this opcode turns into a load and assembles.
+       MOVD $-6795364578871345152, R5  // 3ca00000e8a50000 or 04100000e4a00000
+
        MOVD 8(R3), R4                  // e8830008
        MOVD (R3)(R4), R5               // 7ca4182a
        MOVD (R3)(R0), R5               // 7ca0182a
@@ -90,6 +93,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
        MOVHBR (R3)(R4), R5             // 7ca41e2c
        MOVHBR (R3)(R0), R5             // 7ca01e2c
        MOVHBR (R3), R5                 // 7ca01e2c
+       OR $0, R0, R0
        MOVD $foo+4009806848(FP), R5    // 3ca1ef0138a5cc40 or 0600ef0038a1cc40
        MOVD $foo(SB), R5               // 3ca0000038a50000 or 0610000038a00000
 
index 7e26118bc0a1bc8c1006025c3d8d9ff5ef10cce4..6fa0f8441c75c56b22387bfbef7790afa2fc82e5 100644 (file)
@@ -175,8 +175,8 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
                        // Is this a shifted 16b constant? If so, rewrite it to avoid a creating and loading a constant.
                        val := p.From.Offset
                        shift := bits.TrailingZeros64(uint64(val))
-                       mask := 0xFFFF << shift
-                       if val&int64(mask) == val || (val>>(shift+16) == -1 && (val>>shift)<<shift == val) {
+                       mask := int64(0xFFFF) << shift
+                       if val&mask == val || (val>>(shift+16) == -1 && (val>>shift)<<shift == val) {
                                // Rewrite this value into MOVD $const>>shift, Rto; SLD $shift, Rto
                                q := obj.Appendp(p, c.newprog)
                                q.As = ASLD