]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: use len(s)<=cap(s) to remove more bounds checks
authorKeith Randall <khr@golang.org>
Sun, 27 Nov 2016 19:43:08 +0000 (11:43 -0800)
committerKeith Randall <khr@golang.org>
Thu, 2 Feb 2017 17:45:58 +0000 (17:45 +0000)
commit73f92f9b0405e98427bbb445f24cffb5d3c4d01b
tree05df0d7b52dc6316d6b939d8d817b2f91e8d4595
parent6317f92f6e51f679712deec6094c6b5fc2948a5b
cmd/compile: use len(s)<=cap(s) to remove more bounds checks

When we discover a relation x <= len(s), also discover the relation
x <= cap(s).  That way, in situations like:

a := s[x:]  // tests 0 <= x <= len(s)
b := s[:x]  // tests 0 <= x <= cap(s)

the second check can be eliminated.

Fixes #16813

Change-Id: Ifc037920b6955e43bac1a1eaf6bac63a89cfbd44
Reviewed-on: https://go-review.googlesource.com/33633
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/prove.go
test/checkbce.go
test/prove.go