<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Would it really be more efficient? From my experience iterating over bit arrays, I would much rather unconditionally bsr/bsf/tzcnt/lzcnt to find the next than have complex logic to handle consecutive bits. If you add branchy logic, you’ve lost the entire point of this kind of fast iteration (no branch mispredictions).<div class=""><br class=""></div><div class="">Fiona</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 13, 2017, at 5:58 PM, Matthias Braun via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Doing a `grep "find_first" * -r` over llvm shows you it is a common pattern, which IMO should be something we can do in 1 for. If anything you could rewrite the internal representation to work on strides, but I am not convinced it is worth the complexity today until someone shows me a case where it actually matters.</div><div class=""><br class=""></div><div class="">- Matthias</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Apr 13, 2017, at 5:53 PM, Zachary Turner <<a href="mailto:zturner@google.com" class="">zturner@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Would it really be that unhandy?  You would only need to iterate from iter->first to iter->second to get the same effect.<br class=""><br class="">Granted it wouldn't work with existing algorithms that take predicates or functions with integer arguments, but I wonder if anyone would even notice that limitation.  And when the bits happen to be clustered together , which is not uncommon, it will be vastly more efficient <br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Apr 13, 2017 at 5:44 PM Matthias Braun <<a href="mailto:matze@braunis.de" class="">matze@braunis.de</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">While more efficient, this seems unhandy to me...</div><div class=""><br class=""></div><div class="">Using a BitVector as a replacement for a std::set<unsigned> is a common pattern and in this case I would expect the iterator to return all the elements that I put into the set before...</div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">- Matthias</div></div><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 13, 2017, at 5:41 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank" class="">zturner@google.com</a>> wrote:</div><br class="m_-8876891372759186519Apple-interchange-newline"><div class="">Instead of having the value type be an index, how about having it be a range?  Eg if bits,1,2,3,6,8,9 are set then have it return (1,4), (6,7), and (8,10) on successive iterations.  This should be much more efficient.  For a bits_unset iterator, the above would return (0,1), (4, 6), (7,8), (10, size())<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Apr 13, 2017 at 5:29 PM Matthias Braun via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank" class="">reviews@reviews.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">MatzeB added reviewers: dblaikie, chandlerc, mehdi_amini.<br class="">
MatzeB added a comment.<br class="">
<br class="">
Adding a few reviewers who often have comments on ADT changes.<br class="">
<br class="">
<br class="">
<a href="https://reviews.llvm.org/D32060" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D32060</a><br class="">
<br class="">
<br class="">
<br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></blockquote></div>
</div></blockquote></div><br class=""></div>_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""></div></blockquote></div><br class=""></div></body></html>