Skip to content

cmd/compile: missed opportunity to coalesce reads/writes #41663

@josharian

Description

@josharian
package p

import "encoding/binary"

func f(b []byte, x *[8]byte) {
	_ = b[8]
	t := binary.LittleEndian.Uint64(x[:])
	binary.LittleEndian.PutUint64(b, t)
}

This should compile down to two MOVQs on amd64, one to load from x and one to write to b.

Instead, it compiles to a series of smaller MOVxs. The coalescing rules may need more cases added.

cc @randall77 @dr2chase @martisch @mundaym

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions