golang/go

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

Open

#72831 opened on Mar 12, 2025

View on GitHub
 (11 comments) (3 reactions) (0 assignees)Go (133,883 stars) (19,008 forks)batch import
BugReportNeedsFixPerformancecompiler/runtimehelp wanted

Description

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.

Contributor guide