-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.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.help wanted
Milestone
Description
Go version
go version go1.25-devel_6c3b5a2 Thu Jul 3 18:43:56 2025 -0700 linux/amd64
Output of go env in your module/workspace:
Using service on https://go.godbolt.org/
Selected "x86-64 gc (tip)"What did you do?
I entered following program
package main
func Foo(a [][4]byte, b []int, i int) int {
return b[a[i][1]]
}
func main() {
}https://go.godbolt.org/z/hfvezofxf
What did you see happen?
Codegen for a[i][1] part was following:
LEAQ (AX)(R9*4), DX
LEAQ 1(DX), DX
MOVBLZX (DX), AXWhat did you expect to see?
One-line codegen like MOVBLZX 1(AX)(R9*4), AX was expected
The compiler really worked very hard to optimize codegen regarding various element size of slice a. However, it seems that it missed simple case - when the element size is 2, 4 or 8.
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.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.help wanted