<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 10, 2015, at 9:12 PM, Paul Cantrell via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">David, I found the radical differences in our results troubling, so I did some digging. It turns out that the zip+stride code:</div><div class=""><br class=""></div><div class="">…runs <i class="">much</i> faster if you actually use both i and j inside the loop:</div><div class=""><br class=""></div><div class="">Weird, right? This is with optimization on (default “production” build). It smells like a compiler quirk.</div><div class=""><br class=""></div><div class="">With that tweak, the zip+stride approach actually clocks in faster than the C-style for. Yes, you read that right: <i class="">faster</i>. Also smells like a quirk. Am I doing something fantastically stupid in my code? Or maybe it’s just my idiosyncratic taste in indentation? :P</div></div></div></blockquote><br class=""></div><div>One problem: zip+stride suffers tremendously at -Onone. One test looked like this (normalized elapsed time; smaller is better)</div><div><br class=""></div><div> 1.0 zip+stride -O</div><div> 1.2 for(;;) -O</div><div> 19.3 for(;;) -Onone</div><div>261.7 zip+stride -Onone</div><div><br class=""></div><div>Presumably all of these can be improved with compiler work, but I don't know how far zip+stride can be pushed in the -Onone case.</div><div><br class=""></div><div><br class=""></div><div>-- </div><div>Greg Parker <a href="mailto:gparker@apple.com" class="">gparker@apple.com</a> Runtime Wrangler</div><div><br class=""></div><div><br class=""></div></body></html>