diff options
author | Paul E. Murphy <murp@ibm.com> | 2024-04-22 16:16:30 -0500 |
---|---|---|
committer | Paul Murphy <murp@ibm.com> | 2024-04-24 15:53:25 +0000 |
commit | 3aad2d0765b9f652e1964a8261d6ef0035d9535f (patch) | |
tree | 1b6e4db33900e4b35d64937348dc81e404c6c52d | |
parent | 4792ca7b93d5745647a95ac73a93f9c9b97db499 (diff) | |
download | go-3aad2d0765b9f652e1964a8261d6ef0035d9535f.tar.gz go-3aad2d0765b9f652e1964a8261d6ef0035d9535f.zip |
cmd/internal/obj/ppc64: fix incorrect int to int64 conversion when checking MOVD opcodes
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 #66955
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>
-rw-r--r-- | src/cmd/asm/internal/asm/testdata/ppc64.s | 4 | ||||
-rw-r--r-- | src/cmd/internal/obj/ppc64/obj9.go | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/asm/internal/asm/testdata/ppc64.s b/src/cmd/asm/internal/asm/testdata/ppc64.s index fc56a9530a..8627408f06 100644 --- a/src/cmd/asm/internal/asm/testdata/ppc64.s +++ b/src/cmd/asm/internal/asm/testdata/ppc64.s @@ -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 diff --git a/src/cmd/internal/obj/ppc64/obj9.go b/src/cmd/internal/obj/ppc64/obj9.go index a55c402c44..23196875a5 100644 --- a/src/cmd/internal/obj/ppc64/obj9.go +++ b/src/cmd/internal/obj/ppc64/obj9.go @@ -200,8 +200,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 |