Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: unnecessary bounds checks are not removed #14808
Please answer these questions before submitting your issue. Thanks!
I composed a list of bounds checks that the compiler at tip can and cannot eliminate. For some I provided an alternative implementation.
* This the simplest solution I could came up with that doesn't required changing the compiler. * The bound checks become constants now so they are removed during opt phase. Updates #14808 Change-Id: If32c33d7ec08bb400321b465015d152f0a5d3001 Reviewed-on: https://go-review.googlesource.com/20654 Reviewed-by: Russ Cox <firstname.lastname@example.org> Run-TryBot: Alexandru Moșoi <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org>
A case that maybe could be added to the doc above and loopbce.go is when writing to an array/slice from back to front e.g. for integer formatting:
This currently generates bounds checks but when writing the above with i = 0; i < len(buf); i++ the bounds checks are removed.