FAQ
I've updated the doc
<https://docs.google.com/document/d/1vdAEAjYdzjnPA9WDOQ1e4e05cYVMpqSxJYZT33Cqw2g/edit?usp=sharing>
based on the recent compiler improvements.

In particular the following examples are working as expected.

// using a hint
_ = a[3] // early bounds check
use a[1], a[2], a[3] // no bounds checks

// using decreasing constant indexes
use a[3], a[2], a[1] // one bounds check

// iterating over a slice
for i := range a {
   use a[i] // no bounds check
}


Find more examples in test/prove.go
<https://go.googlesource.com/go/+/master/test/prove.go> and in
test/loopbce.go <https://go.googlesource.com/go/+/master/test/loopbce.go>.

Again, I'm interested to know examples (especially from stdlib) where the
compiler doesn't do a good job to eliminate bounds. If you think it should
please file a bug explaining why (but make sure to check the examples
first).


joi, 17 martie 2016, 16:08:49 UTC+1, Alexandru Moșoi a scris:
Hi, golang-dev!

Some of you may already have seen it, I wrote a document on the current
state of bounds-checking elimination. The document is here
<https://docs.google.com/document/d/1vdAEAjYdzjnPA9WDOQ1e4e05cYVMpqSxJYZT33Cqw2g/edit> and
linked from #14808 <https://github.com/golang/go/issues/14808>.

You can request edit/comment permissions by clicking View Only -> Request
edit access. Alternatively, you can leave your questions and comments here.
The feedback I'm looking are examples that show performance regression when
bounds checks are enabled. By default bounds checks are enabled, but they
can be disabled with -gcflags=-B.

Regards,
--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 15 | next ›
Discussion Overview
groupgolang-dev @
categoriesgo
postedMar 17, '16 at 3:08p
activeApr 11, '16 at 2:00a
posts15
users6
websitegolang.org

People

Translate

site design / logo © 2023 Grokbase