Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upcmd/compile: unnecessary bounds check #29872
Comments
This comment has been minimized.
This comment has been minimized.
Please use the issue template. You don't specify what version of Go, for one, or which compiler. |
bradfitz
added
the
WaitingForInfo
label
Jan 22, 2019
This comment has been minimized.
This comment has been minimized.
Oh, I see your link goes to a site where "gc (tip)" is selected. But it's faster for us if you put all the relevant information in the bug. And conventionally we share play.golang.org code snippets. But in this case you can just inline the code: package test
func test(slc []byte, i uint) {
if len(slc) >= 3 {
_ = slc[i%3]
}
} /cc @randall77 @aclements |
bradfitz
added
Performance
help wanted
NeedsInvestigation
and removed
WaitingForInfo
labels
Jan 22, 2019
bradfitz
added this to the Go1.13 milestone
Jan 22, 2019
This comment has been minimized.
This comment has been minimized.
Sorry, @bradfitz. I just assumed that you were familiar with Godbolt and, as you found out, the version is displayed there. But I'll take note for future reference. |
This comment has been minimized.
This comment has been minimized.
I think this would just involve adding a new case for unsigned remainder to the prove pass. |
This comment has been minimized.
This comment has been minimized.
cc @rasky |
marigonzes commentedJan 22, 2019
•
edited
What did you do?
I compiled the following program to see its assembly code: https://godbolt.org/z/OcRvPE
What did you expect to see?
I expected the access to the slice to not be bounds checked
What did you see instead?
A bounds check was generated by the Go compiler