cmd/compile: unnecessary bounds check in a loop passed as a closure #39756
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, using
amd64 gc (tip)
on go.godbolt.org.What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I loaded the following program into go.godbolt.org:
https://go.godbolt.org/z/iPaz7f
What did you expect to see?
I expected that the bounds check for
c[i]
would be eliminated because of the early bounds check triggered byc[n-1]
, the way that it would if the inner loop wasn't sent as a closure torun
.This should be possible because
c
doesn't get assigned to within the closure.What did you see instead?
The compiler emits a bounds check for
c[i]
.The text was updated successfully, but these errors were encountered: