Skip to content

Commit

Permalink
Move vectorizability test to boundscheck_exec.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed May 14, 2018
1 parent b880403 commit bfd8462
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
10 changes: 1 addition & 9 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ isdefined(Main, :TestHelpers) || @eval Main include("TestHelpers.jl")
using .Main.TestHelpers.OAs
using SparseArrays

using Random, LinearAlgebra, InteractiveUtils
using Random, LinearAlgebra

@testset "basics" begin
@test length([1, 2, 3]) == 3
Expand Down Expand Up @@ -2431,16 +2431,8 @@ function f27079()
end
length(X)
end
function g27079(X)
r = 0
@inbounds for x in X
r += x
end
r
end
@testset "iteration over resized vector" begin
@test f27079() == 0
@test occursin("vector.body", sprint(code_llvm, g27079, Tuple{Vector{Int}}))
end

@testset "indices-related shape promotion errors" begin
Expand Down
15 changes: 14 additions & 1 deletion test/boundscheck_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module TestBoundsCheck

using Test, Random
using Test, Random, InteractiveUtils

@enum BCOption bc_default bc_on bc_off
bc_opt = BCOption(Base.JLOptions().check_bounds)
Expand Down Expand Up @@ -239,4 +239,17 @@ if bc_opt != bc_off
@test_throws BoundsError BadVector20469([1,2,3])[:]
end

# Ensure iteration over arrays is vectorizable with boundschecks off
function g27079(X)
r = 0
@inbounds for x in X
r += x
end
r
end
if bc_opt == bc_default || bc_opt == bc_off
@test occursin("vector.body", sprint(code_llvm, g27079, Tuple{Vector{Int}}))
end


end

0 comments on commit bfd8462

Please sign in to comment.