diff --git a/test/arrayops.jl b/test/arrayops.jl index e4fbbdd3d18ae..53fe39b2ff6ec 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -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 @@ -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 diff --git a/test/boundscheck_exec.jl b/test/boundscheck_exec.jl index 138059d8fcb8a..62a20921bd44e 100644 --- a/test/boundscheck_exec.jl +++ b/test/boundscheck_exec.jl @@ -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) @@ -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