Skip to content

cmd/compile: use some partial register instructions on amd64? #37593

@josharian

Description

@josharian

This is the standard way to check whether a value is 32 bit:

func is32bit(x int64) bool {
	return x == int64(int32(x))
}

On amd64, this compiles to a MOVLQSX and a CMPQ. However, it could compile to just a TESTL of the top half of the register.

Is there a reason that we don't have any optimizations like this, other than that no one has bothered to write any yet?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions