Missed optimization opportunity?

I'm 99.999% sure you are mistaken here (see the command line compilation flags I used in the original post). I have tested this with Xcode 9.3 beta 3, default toolchain and dev snapshot 2018-02-25.

Start a new command line app prj in Xcode, replace the content in main.swift with:

import AppKit
    
let a = Double(1)
var checksum = UInt64(0)
for _ in 0 ..< 5 {
    let t0 = CACurrentMediaTime()
    for _ in 0 ..< 1_000_000_000 {
        let v = a.nextDown
        checksum = checksum &+ v.bitPattern
    }
    let t1 = CACurrentMediaTime()
    print(t1 - t0, "seconds, checksum:", checksum)
}

Run it (a release build of course : ) ) and note that each of the 5 trials will take (probably, if your machine is anything like my MBP) a couple of seconds.

If this is really blazing fast for you, what Xcode (and Swift) version are you using?

And also, to make the point of this thread clear, here is a version that is "manually optimized" so that it works the way I expect it to when the compiler optimizes it for me:

import AppKit

let a = Double(1)
var checksum = UInt64(0)
for _ in 0 ..< 5 {
    let t0 = CACurrentMediaTime()
    let v = a.nextDown // <-- Moved this outside the loop.
    for _ in 0 ..< 1_000_000_000 {
        checksum = checksum &+ v.bitPattern
    }
    let t1 = CACurrentMediaTime()
    print(t1 - t0, "seconds, checksum:", checksum)
}

This will be very fast.