[swift-evolution] [Review] SE-0007 Remove C-style for-loops with conditions and incrementers

Greg Parker gparker at apple.com
Thu Dec 10 23:34:51 CST 2015


> On Dec 10, 2015, at 9:12 PM, Paul Cantrell via swift-evolution <swift-evolution at swift.org> wrote:
> 
> David, I found the radical differences in our results troubling, so I did some digging. It turns out that the zip+stride code:
> 
> …runs much faster if you actually use both i and j inside the loop:
> 
> Weird, right? This is with optimization on (default “production” build). It smells like a compiler quirk.
> 
> With that tweak, the zip+stride approach actually clocks in faster than the C-style for. Yes, you read that right: faster. 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

One problem: zip+stride suffers tremendously at -Onone. One test looked like this (normalized elapsed time; smaller is better)

  1.0  zip+stride -O
  1.2  for(;;) -O
 19.3  for(;;) -Onone
261.7  zip+stride -Onone

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.


-- 
Greg Parker     gparker at apple.com     Runtime Wrangler


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151210/dbdf2e3c/attachment.html>


More information about the swift-evolution mailing list