cmd/compile/internal/ssa: combine more shift and masking on PPC64

Investigating binaries, these patterns seem to show up frequently.

Change-Id: I987251e4070e35c25e98da321e444ccaa1526912
Reviewed-on: https://go-review.googlesource.com/c/go/+/583302
Reviewed-by: Cherry Mui <cherryyz@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: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Paul E. Murphy 2024-05-01 15:03:34 -05:00 committed by Paul Murphy
parent bbdad50c09
commit 0222a028f1
4 changed files with 261 additions and 1 deletions

View file

@ -467,11 +467,32 @@ func checkMergedShifts64(a [256]uint32, b [256]uint64, v uint64) {
// ppc64x: "SRD", "CLRLSLDI", -"RLWNM"
a[5] = a[(v>>32)&0x01]
// ppc64x: "SRD", "CLRLSLDI", -"RLWNM"
a[5] = a[(v>>34)&0x03]
a[6] = a[(v>>34)&0x03]
// ppc64x: -"CLRLSLDI", "RLWNM\t[$]12, R[0-9]+, [$]21, [$]28, R[0-9]+"
b[0] = b[uint8(v>>23)]
// ppc64x: -"CLRLSLDI", "RLWNM\t[$]15, R[0-9]+, [$]21, [$]28, R[0-9]+"
b[1] = b[(v>>20)&0xFF]
// ppc64x: "RLWNM", -"SLD"
b[2] = b[((uint64((uint32(v) >> 21)) & 0x3f) << 4)]
}
func checkShiftMask(a uint32, b uint64, z []uint32, y []uint64) {
_ = y[128]
_ = z[128]
// ppc64x: -"MOVBZ", -"SRW", "RLWNM"
z[0] = uint32(uint8(a >> 5))
// ppc64x: -"MOVBZ", -"SRW", "RLWNM"
z[1] = uint32(uint8((a >> 4) & 0x7e))
// ppc64x: "RLWNM\t[$]25, R[0-9]+, [$]27, [$]29, R[0-9]+"
z[2] = uint32(uint8(a>>7)) & 0x1c
// ppc64x: -"MOVWZ"
y[0] = uint64((a >> 6) & 0x1c)
// ppc64x: -"MOVWZ"
y[1] = uint64(uint32(b)<<6) + 1
// ppc64x: -"MOVHZ", -"MOVWZ"
y[2] = uint64((uint16(a) >> 9) & 0x1F)
// ppc64x: -"MOVHZ", -"MOVWZ", -"ANDCC"
y[3] = uint64(((uint16(a) & 0xFF0) >> 9) & 0x1F)
}
// 128 bit shifts