-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
The instructions generated by the Go compiler for the code below contain too many unnecessary register copies.
//go:noinline
func swap(x, y float64) (float64, float64) {
if y > x {
x, y = y, x
}
return x, y
}
The assembly instructions:
0x0000 00000 (p.go:9) TEXT main.swap(SB), LEAF|NOFRAME|ABIInternal, $0-16
0x0000 00000 (p.go:10) FCMPD F1, F0
0x0004 00004 (p.go:10) BMI 20
0x0008 00008 (p.go:13) FMOVD F1, F2
0x000c 00012 (p.go:13) FMOVD F0, F1
0x0010 00016 (p.go:13) FMOVD F2, F0
0x0014 00020 (p.go:13) FMOVD F0, F2
0x0018 00024 (p.go:13) FMOVD F1, F0
0x001c 00028 (p.go:13) FMOVD F2, F1
0x0020 00032 (p.go:13) RET (R30)
The expected instruction sequence:
0x0000 00000 (p.go:9) TEXT main.swap(SB), LEAF|NOFRAME|ABIInternal, $0-16
0x0000 00000 (p.go:10) FCMPD F1, F0
0x0004 00004 (p.go:10) BPL 20
0x0008 00008 (p.go:13) FMOVD F1, F2
0x000c 00012 (p.go:13) FMOVD F0, F1
0x0010 00016 (p.go:13) FMOVD F2, F0
0x0020 00020 (p.go:13) RET (R30)
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.