cmd/compile: unnecessary bounds check in a loop passed as a closure #39756
Labels
Milestone
Comments
It's not just the bounds check, it is also reloading the backing store pointer every time. You can fix this by doing
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: