1
0
mirror of https://github.com/golang/go synced 2024-11-25 07:07:57 -07:00

cmd/compile/internal/ssa: fix ppc64 merging of (CLRLSLDI (SRD ...))

The rotate value was not correctly converted from a 64 bit to 32
bit rotate. This caused a miscompile of
golang.org/x/text/unicode/runenames.Names.

Fixes #67526

Change-Id: Ief56fbab27ccc71cd4c01117909bfee7f60a2ea1
Reviewed-on: https://go-review.googlesource.com/c/go/+/586915
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
Paul E. Murphy 2024-05-20 14:44:21 -05:00 committed by Paul Murphy
parent 3bcefa5276
commit c6d142c4a7
2 changed files with 6 additions and 2 deletions

View File

@ -1631,7 +1631,7 @@ func mergePPC64ClrlsldiSrd(sld, srd int64) int64 {
if v1&mask_3 != 0 {
return 0
}
return encodePPC64RotateMask(int64(r_3-32), int64(mask_3), 32)
return encodePPC64RotateMask(int64(r_3&31), int64(mask_3), 32)
}
// Test if a RLWINM feeding into a CLRLSLDI can be merged into RLWINM. Return

View File

@ -453,7 +453,7 @@ func checkMergedShifts32(a [256]uint32, b [256]uint64, u uint32, v uint32) {
b[2] = b[v>>25]
}
func checkMergedShifts64(a [256]uint32, b [256]uint64, v uint64) {
func checkMergedShifts64(a [256]uint32, b [256]uint64, c [256]byte, v uint64) {
// ppc64x: -"CLRLSLDI", "RLWNM\t[$]10, R[0-9]+, [$]22, [$]29, R[0-9]+"
a[0] = a[uint8(v>>24)]
// ppc64x: "SRD", "CLRLSLDI", -"RLWNM"
@ -474,6 +474,10 @@ func checkMergedShifts64(a [256]uint32, b [256]uint64, v uint64) {
b[1] = b[(v>>20)&0xFF]
// ppc64x: "RLWNM", -"SLD"
b[2] = b[((uint64((uint32(v) >> 21)) & 0x3f) << 4)]
// ppc64x: "RLWNM\t[$]11, R[0-9]+, [$]10, [$]15"
c[0] = c[((v>>5)&0x3F)<<16]
// ppc64x: "RLWNM\t[$]0, R[0-9]+, [$]19, [$]24"
c[1] = c[((v>>7)&0x3F)<<7]
}
func checkShiftMask(a uint32, b uint64, z []uint32, y []uint64) {