Skip to content

Instantly share code, notes, and snippets.

@damiendr
Created August 20, 2018 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damiendr/c21781be4b162f72ed1021f66af595cf to your computer and use it in GitHub Desktop.
Save damiendr/c21781be4b162f72ed1021f66af595cf to your computer and use it in GitHub Desktop.
Works as expected --- (Base.arrayref)(false, xs, i) in @code_typed:
```
function update(xs, i)
@inbounds xs[i] += 1
end
```
`@inbounds` ignored --- (Base.arrayref)(true, xs, i) in @code_typed:
```
@inbounds function update(xs, i)
xs[i] += 1
end
```
`@simd` fails to vectorize --- (Base.arrayref)(true, xs, i) in @code_typed:
```
@inline function update(xs, i)
xs[i] += 1
end
@inbounds @simd for i in eachindex(xs)
update(xs, i)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment