Skip to content

cmd/compile: coalesce adjacent writes to struct fields #66413

@dsnet

Description

@dsnet

Go version

go1.22

Output of go env in your module/workspace:

GOARCH=amd64
GOOS=linux

What did you do?

Compile the following:

var sink A

func main() {
	sink = A{31, false, true, 12}
}

type A struct {
	a byte
	b bool
	c bool
	d int8
}

What did you see happen?

The compiler output something like:

0x0000 00000 (main.go:13)	MOVB	$31, main.sink(SB)
0x0007 00007 (main.go:13)	MOVB	$0, main.sink+1(SB)
0x000e 00014 (main.go:13)	MOVB	$1, main.sink+2(SB)
0x0015 00021 (main.go:13)	MOVB	$12, main.sink+3(SB)

What did you expect to see?

A single MOVL instruction.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions