Merged
Conversation
This would previously have been an infinite loop if `length(A) == typemax(Int)` so the loop vectorizer couldn't compute a trip count.
Member
Author
|
Actually, maybe we should we start L31: cmpq %r8, %rcx
jae L82
movq (%rdi), %rdx
Source line: 4
Source line: [inline] float.jl:269
subq %rsi, %rdx
vcmpneqsd (%rdx), %xmm0, %xmm1
vmovd %xmm1, %edx
andl $1, %edx
addq $-8, %rsi
Source line: 3
incq %rcx
Source line: 4
Source line: [inline] float.jl:269
addq %rdx, %rax
cmpq %rcx, %r8
jne L31vs. L37: cmpq %r8, %rcx
jae L95
Source line: 4
Source line: [inline] float.jl:269
leaq (,%rsi,8), %r10
Source line: 3
movq (%rdi), %rdx
Source line: 4
Source line: [inline] float.jl:269
subq %r10, %rdx
vcmpneqsd (%rdx), %xmm0, %xmm1
vmovd %xmm1, %edx
andl $1, %edx
incq %rcx
decq %rsi
addq %rdx, %rax
cmpq %rsi, %r9
jne L37OTOH, LLVM 3.6 appears to be smarter and this doesn't make a difference there, so maybe this isn't worth it? |
Member
|
Possibly related to #9182. |
simonster
added a commit
that referenced
this pull request
Nov 4, 2015
Vectorize `@ inbounds for x in A ...`
Member
|
This would deserve a comment explaining why the function isn't written in the most natural way. Especially since this isn't covered by the tests, which means anybody might break this by rewriting it to an apparently better form. |
mbauman
added a commit
that referenced
this pull request
May 11, 2018
Currently, if a vector is resized in the midst of iteration, then `done` might "miss" the end of iteration. This trivially changes the definition to catch such a case. I am not sure what guarantees we make about mutating iterables during iteration, but this seems simple and easy to support. Note, though, that it is somewhat tricky: until #13866 we used `i > length(a)`, but that foils vectorization due to the `typemax` case. This definition seems to get the best of both worlds. For a definition like `f` below, this new definition just requires one extra `add i64` operation in the preamble (before the loop). Everything else is identical to master. ```julia function f(A) r = 0 @inbounds for x in A r += x end r end ```
mbauman
added a commit
that referenced
this pull request
May 14, 2018
Currently, if a vector is resized in the midst of iteration, then `done` might "miss" the end of iteration. This trivially changes the definition to catch such a case. I am not sure what guarantees we make about mutating iterables during iteration, but this seems simple and easy to support. Note, though, that it is somewhat tricky: until #13866 we used `i > length(a)`, but that foils vectorization due to the `typemax` case. This definition seems to get the best of both worlds. For a definition like `f` below, this new definition just requires one extra `add i64` operation in the preamble (before the loop). Everything else is identical to master. ```julia function f(A) r = 0 @inbounds for x in A r += x end r end ```
mbauman
added a commit
that referenced
this pull request
May 15, 2018
* More robust iteration over Vectors Currently, if a vector is resized in the midst of iteration, then `done` might "miss" the end of iteration. This trivially changes the definition to catch such a case. I am not sure what guarantees we make about mutating iterables during iteration, but this seems simple and easy to support. Note, though, that it is somewhat tricky: until #13866 we used `i > length(a)`, but that foils vectorization due to the `typemax` case. This definition seems to get the best of both worlds. For a definition like `f` below, this new definition just requires one extra `add i64` operation in the preamble (before the loop). Everything else is identical to master. ```julia function f(A) r = 0 @inbounds for x in A r += x end r end ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This would previously have been an infinite loop if
length(A) == typemax(Int)so the loop vectorizer couldn't compute a trip count. Ref #13860 (comment)