golang/go

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

Open

#72,831 建立於 2025年3月12日

在 GitHub 查看
 (11 留言) (3 反應) (0 負責人)Go (133,883 star) (19,008 fork)batch import
BugReportNeedsFixPerformancecompiler/runtimehelp wanted

描述

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.

貢獻者指南