Skip to content

Commit

Permalink
Minor boundscheck test refactoring.
Browse files Browse the repository at this point in the history
Write in a way which makes it more explicit what is inlined vs not inlined.
  • Loading branch information
blakejohnson committed Jan 6, 2016
1 parent 435e5fc commit 6646136
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions test/boundscheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ using Base.Test
return r
end

@noinline function A1_noinline()
r = 0
@boundscheck r += 1
return r
end

function A1_inbounds()
r = 0
@inbounds begin
Expand All @@ -21,8 +27,8 @@ end
@test A1() == 1
@test A1_inbounds() == 0

# test for boundscheck block eliminated one layer deep
function A2()
# test for boundscheck block eliminated one layer deep, if the called method is inlined
@inline function A2()
r = A1()+1
return r
end
Expand All @@ -32,8 +38,14 @@ function A2_inbounds()
return r
end

function A2_notinlined()
@inbounds r = A1_noinline()+1
return r
end

@test A2() == 2
@test A2_inbounds() == 1
@test A2_notinlined() == 2

# test boundscheck NOT eliminated two layers deep

Expand All @@ -50,14 +62,6 @@ end
@test A3() == 3
@test A3_inbounds() == 3

@inline B() = A1() + 1
function A3_inbounds2()
@inbounds r = B()+1
return r
end

@test A3_inbounds2() == 3

# swapped nesting order of @boundscheck and @inbounds
function A1_nested()
r = 0
Expand Down

0 comments on commit 6646136

Please sign in to comment.