Skip to content

Commit c6d142c

Browse files
committed
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Lynn Boger <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 3bcefa5 commit c6d142c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/cmd/compile/internal/ssa/rewrite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ func mergePPC64ClrlsldiSrd(sld, srd int64) int64 {
16311631
if v1&mask_3 != 0 {
16321632
return 0
16331633
}
1634-
return encodePPC64RotateMask(int64(r_3-32), int64(mask_3), 32)
1634+
return encodePPC64RotateMask(int64(r_3&31), int64(mask_3), 32)
16351635
}
16361636

16371637
// Test if a RLWINM feeding into a CLRLSLDI can be merged into RLWINM. Return

test/codegen/shift.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func checkMergedShifts32(a [256]uint32, b [256]uint64, u uint32, v uint32) {
453453
b[2] = b[v>>25]
454454
}
455455

456-
func checkMergedShifts64(a [256]uint32, b [256]uint64, v uint64) {
456+
func checkMergedShifts64(a [256]uint32, b [256]uint64, c [256]byte, v uint64) {
457457
// ppc64x: -"CLRLSLDI", "RLWNM\t[$]10, R[0-9]+, [$]22, [$]29, R[0-9]+"
458458
a[0] = a[uint8(v>>24)]
459459
// ppc64x: "SRD", "CLRLSLDI", -"RLWNM"
@@ -474,6 +474,10 @@ func checkMergedShifts64(a [256]uint32, b [256]uint64, v uint64) {
474474
b[1] = b[(v>>20)&0xFF]
475475
// ppc64x: "RLWNM", -"SLD"
476476
b[2] = b[((uint64((uint32(v) >> 21)) & 0x3f) << 4)]
477+
// ppc64x: "RLWNM\t[$]11, R[0-9]+, [$]10, [$]15"
478+
c[0] = c[((v>>5)&0x3F)<<16]
479+
// ppc64x: "RLWNM\t[$]0, R[0-9]+, [$]19, [$]24"
480+
c[1] = c[((v>>7)&0x3F)<<7]
477481
}
478482

479483
func checkShiftMask(a uint32, b uint64, z []uint32, y []uint64) {

0 commit comments

Comments
 (0)