mirror of
https://github.com/golang/go
synced 2024-11-15 00:20:30 -07:00
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>
This commit is contained in:
parent
4792ca7b93
commit
3aad2d0765
4
src/cmd/asm/internal/asm/testdata/ppc64.s
vendored
4
src/cmd/asm/internal/asm/testdata/ppc64.s
vendored
@ -52,6 +52,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
|
|||||||
// Hex constant 0xFFFFFFFE00000001
|
// Hex constant 0xFFFFFFFE00000001
|
||||||
MOVD $-8589934591, R5 // 38a0ffff or 0602000038a00001
|
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 8(R3), R4 // e8830008
|
||||||
MOVD (R3)(R4), R5 // 7ca4182a
|
MOVD (R3)(R4), R5 // 7ca4182a
|
||||||
MOVD (R3)(R0), R5 // 7ca0182a
|
MOVD (R3)(R0), R5 // 7ca0182a
|
||||||
@ -90,6 +93,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
|
|||||||
MOVHBR (R3)(R4), R5 // 7ca41e2c
|
MOVHBR (R3)(R4), R5 // 7ca41e2c
|
||||||
MOVHBR (R3)(R0), R5 // 7ca01e2c
|
MOVHBR (R3)(R0), R5 // 7ca01e2c
|
||||||
MOVHBR (R3), R5 // 7ca01e2c
|
MOVHBR (R3), R5 // 7ca01e2c
|
||||||
|
OR $0, R0, R0
|
||||||
MOVD $foo+4009806848(FP), R5 // 3ca1ef0138a5cc40 or 0600ef0038a1cc40
|
MOVD $foo+4009806848(FP), R5 // 3ca1ef0138a5cc40 or 0600ef0038a1cc40
|
||||||
MOVD $foo(SB), R5 // 3ca0000038a50000 or 0610000038a00000
|
MOVD $foo(SB), R5 // 3ca0000038a50000 or 0610000038a00000
|
||||||
|
|
||||||
|
@ -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.
|
// Is this a shifted 16b constant? If so, rewrite it to avoid a creating and loading a constant.
|
||||||
val := p.From.Offset
|
val := p.From.Offset
|
||||||
shift := bits.TrailingZeros64(uint64(val))
|
shift := bits.TrailingZeros64(uint64(val))
|
||||||
mask := 0xFFFF << shift
|
mask := int64(0xFFFF) << shift
|
||||||
if val&int64(mask) == val || (val>>(shift+16) == -1 && (val>>shift)<<shift == val) {
|
if val&mask == val || (val>>(shift+16) == -1 && (val>>shift)<<shift == val) {
|
||||||
// Rewrite this value into MOVD $const>>shift, Rto; SLD $shift, Rto
|
// Rewrite this value into MOVD $const>>shift, Rto; SLD $shift, Rto
|
||||||
q := obj.Appendp(p, c.newprog)
|
q := obj.Appendp(p, c.newprog)
|
||||||
q.As = ASLD
|
q.As = ASLD
|
||||||
|
Loading…
Reference in New Issue
Block a user