Optimize/eliminate bounds checking

TODO: do better at it by tracking min/max values of integers. The
following straightforward code doesn't have its bounds checks removed:

    for _, n := range slice {
        println(n)
    }
This commit is contained in:
Ayke van Laethem
2018-09-02 16:24:50 +02:00
parent 42cddd3260
commit 88b6b2e7f5
7 changed files with 48 additions and 19 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ func _panic(message interface{}) {
abort()
}
// Check for bounds in *ssa.IndexAddr and *ssa.Lookup.
// Check for bounds in *ssa.Index, *ssa.IndexAddr and *ssa.Lookup.
func lookupBoundsCheck(length, index int) {
if index < 0 || index >= length {
// printstring() here is safe as this function is excluded from bounds