]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix offset calculation error in memcombine
authorJunyang Shao <shaojunyang@google.com>
Wed, 21 May 2025 18:50:39 +0000 (18:50 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 21 May 2025 19:17:08 +0000 (12:17 -0700)
Fixes #73812

Change-Id: If7a6e103ae9e1442a2cf4a3c6b1270b6a1887196
Reviewed-on: https://go-review.googlesource.com/c/go/+/675175
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/ssa/memcombine.go
test/codegen/issue72832.go

index 416f5540a7f0f59097834704616e4c344f5d13d9..b8fcd3949595cd1403c9717590e48e0323963833 100644 (file)
@@ -581,7 +581,7 @@ func combineStores(root *Value) {
                        mask := int64(1)<<(8*a[i].size) - 1
                        s := 8 * (a[i].offset - a[0].offset)
                        if root.Block.Func.Config.BigEndian {
-                               s = aTotalSize*8 - a[i].size - s
+                               s = (aTotalSize-a[i].size)*8 - s
                        }
                        c |= (a[i].store.Args[1].AuxInt & mask) << s
                }
index a7f6ca8c5c9c3a3a313a8c38bf1b22cfe703f48c..392b41b17337737a95deff69dd19d3fd5ab1e86a 100644 (file)
@@ -35,7 +35,16 @@ type tile3 struct {
 
 func store_shifted(t *tile3, x uint32) {
        // amd64:`MOVL`
+       // ppc64:`MOVHBR`
        t.a = uint8(x)
        t.b = uint8(x >> 8)
        t.c = uint16(x >> 16)
 }
+
+func store_const(t *tile3) {
+       // 0x00030201
+       // amd64:`MOVL\s\$197121`
+       // 0x01020003
+       // ppc64:`MOVD\s\$16908291`
+       t.a, t.b, t.c = 1, 2, 3
+}