Skip to content

cmd/compile: suboptimal zeroing of multiple registers on amd64 #76449

@fice-t

Description

@fice-t

Go version

go version go1.26-devel_e88be8a Sun Nov 23 09:07:32 2025 -0800 linux/amd64

Output of go env in your module/workspace:

Workspace is `go.godbolt.org` on `x86-64 gc (tip)` as above.

What did you do?

[Code+output tested here]

Compile this simplified example:

var someError error

func f(w bool) (int, int, int, error) {
	if w {
		return 0, 0, 0, someError
	}
	return 1, 2, 1, nil
}

What did you see happen?

The output for 0, 0, 0 above uses XORL and two MOVQ:

        XORL    AX, AX
        MOVQ    AX, BX
        MOVQ    AX, CX

What did you expect to see?

All zeroing of registers here should use XORL.

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.ImplementationIssues describing a semantics-preserving change to the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions