cmd/compile: fix memcombine pass for big endian, > 1 byte elements

The shift amounts were wrong in this case, leading to miscompilation
of load combining.

Also the store combining was not triggering when it should.

Fixes #64468

Change-Id: Iaeb08972c5fc1d6f628800334789c6af7216e87b
Reviewed-on: https://go-review.googlesource.com/c/go/+/546355
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Keith Randall 2023-11-30 10:04:16 -08:00 committed by Keith Randall
parent 76d90a34dd
commit bda1ef13f8
3 changed files with 169 additions and 6 deletions

View file

@ -882,3 +882,40 @@ func wideStore2(p *[8]uint64, x, y uint64) {
// s390x:-"STMG",-"MOVD"
p[1] = y
}
func store32le(p *struct{ a, b uint32 }, x uint64) {
// amd64:"MOVQ",-"MOVL",-"SHRQ"
// arm64:"MOVD",-"MOVW",-"LSR"
// ppc64le:"MOVD",-"MOVW",-"SRD"
p.a = uint32(x)
// amd64:-"MOVL",-"SHRQ"
// arm64:-"MOVW",-"LSR"
// ppc64le:-"MOVW",-"SRD"
p.b = uint32(x >> 32)
}
func store32be(p *struct{ a, b uint32 }, x uint64) {
// ppc64:"MOVD",-"MOVW",-"SRD"
// s390x:"MOVD",-"MOVW",-"SRD"
p.a = uint32(x >> 32)
// ppc64:-"MOVW",-"SRD"
// s390x:-"MOVW",-"SRD"
p.b = uint32(x)
}
func store16le(p *struct{ a, b uint16 }, x uint32) {
// amd64:"MOVL",-"MOVW",-"SHRL"
// arm64:"MOVW",-"MOVH",-"UBFX"
// ppc64le:"MOVW",-"MOVH",-"SRW"
p.a = uint16(x)
// amd64:-"MOVW",-"SHRL"
// arm64:-"MOVH",-"UBFX"
// ppc64le:-"MOVH",-"SRW"
p.b = uint16(x >> 16)
}
func store16be(p *struct{ a, b uint16 }, x uint32) {
// ppc64:"MOVW",-"MOVH",-"SRW"
// s390x:"MOVW",-"MOVH",-"SRW"
p.a = uint16(x >> 16)
// ppc64:-"MOVH",-"SRW"
// s390x:-"MOVH",-"SRW"
p.b = uint16(x)
}