Simple loop won't vectorize

I am seeing the same thing:

julia> @btime (s = 0.0; @simd for i in 1:10^9 s += i * 1.23 end; s)
  713.254 ms (0 allocations: 0 bytes)
6.150000006112102e17

julia> @btime (s = 0.0; @simd for i in Int32(1):Int32(10^9) s += i * 1.23 end; s)
  130.840 ms (0 allocations: 0 bytes)
6.150000006112102e17

Both cases seem to SIMD, based on the native code, but only the Int32 case generates sane code. I’d love to understand what’s going on here.

7 Likes