Skip to content

cmd/compile: doesn't optimize float comparison to MINSDΒ #72831

@dominikh

Description

@dominikh

Go version

go version go1.24.1 linux/amd64

Output of go env in your module/workspace:

-

What did you do?

go build -gcflags=-S

func mymin(a, b float64) float64 {
	if a < b {
		return a
	} else {
		return b
	}
}

What did you see happen?

0x0000 00000 (bar.go:4)      UCOMISD X0, X1
0x0004 00004 (bar.go:4)      JLS     7
0x0006 00006 (bar.go:5)      RET
0x0007 00007 (bar.go:7)      MOVUPS  X1, X0
0x000a 00010 (bar.go:7)      RET

What did you expect to see?

I think

MINSD X1, X0
RET

but maybe

MINSD X0, X1
MOVUPS X1, X0
RET

AT&T argument order has me thoroughly confused at times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsFixThe path to resolution is known, but the work has not been done.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions