Skip to content

Commit

Permalink
fix scoping of loop variable (#29730)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Oct 22, 2018
1 parent 1db6047 commit 4277da7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 0 additions & 2 deletions base/simdloop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ function compile(x, ivdep)
$(Expr(:simdloop, ivdep)) # Mark loop as SIMD loop
end
end
# Set index to last value just like a regular for loop would
$var = last($r)
end
end
end
Expand Down
15 changes: 10 additions & 5 deletions test/simdloop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,24 @@ for T in [Int32,Int64,Float32,Float64]
end

# Test that scope rules match regular for
let j=4
let j=4, k=4
# Use existing local variable.
@simd for j=1:0 end
@test j==4
for k=1:0 end
@test j==k
@simd for j=1:3 end
@test j==3
for k=1:3 end
@test j==k

# Use global variable
global simd_glob = 4
global glob = 4
@simd for simd_glob=1:0 end
@test simd_glob==4
for glob=1:0 end
@test simd_glob==glob
@simd for simd_glob=1:3 end
@test simd_glob==3
for glob=1:3 end
@test simd_glob==glob

# Index that is local to loop
@simd for simd_loop_local=1:0 end
Expand Down

0 comments on commit 4277da7

Please sign in to comment.