cmd/compile: avoid unnecessary calls to runtime.panicIndex #37740
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 go1.14 windows/amd64
What did you do?
https://play.golang.org/p/uFSviGB2UL3
What did you expect to see?
The generated machine code contains zero calls to
runtime.panicIndex
since all index calculations are safe, and this can be proven easily.As a bonus, the code generator should recognize that the pattern
parts[n - x]
appears repeatedly with varying small constants forx
. There is no need to calculate the expression16 * n
repeatedly in lines 30 to 33.What did you see instead?
go tool objdump -s joinCambridge
contains 7 calls toruntime.panicIndex
.The text was updated successfully, but these errors were encountered: