go/test/codegen/deadstore.go
Keith Randall 7c074f14e6 cmd/compile: use position of nil check when merging it with subsequent store
Semantically the nil check happens first, so we want the position of
the nil check.

In CL 659317 I added the don't-merge-with-store logic. Turns out that
was not right, it was just a way to work around the problem that I
have just fixed in the previous CL in this stack.

Fixes #79762

Change-Id: Id84d89d1843cc07b6f880f68d881c510d742c5aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/785440
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2026-06-09 10:32:41 -07:00

35 lines
660 B
Go

// asmcheck
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package codegen
type S struct {
a, b, c, d, e int
}
func f1(s *S) {
// amd64:-`MOVUPS X15`
// arm64:`FSTPQ` -`STP \(ZR, ZR\)` -`MOVD ZR`
*s = S{}
// arm64:`MOVD \$7` `MOVD R[0-9]+, 32\(R[0-9]+\)`
*s = S{a: 3, b: 4, c: 5, d: 6, e: 7}
}
func f2(s *S) {
// amd64:`MOVQ \$3`
// arm64:-`FSTPQ`
*s = S{a: 1, b: 2, c: 3, d: 4, e: 5}
// amd64:-`MOVQ`
s.a = 3
// amd64:`MOVQ \$4`
s.b = 4
// amd64:`MOVQ \$5`
s.c = 5
// amd64:`MOVQ \$6`
s.d = 6
// amd64:`MOVQ \$7`
s.e = 7
}