-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for bounds check elimination.
- Loading branch information
1 parent
a6f6519
commit 04cce56
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
module TestBoundsCheck | ||
|
||
using Base.Test | ||
|
||
# test for boundscheck block elision at same level | ||
function A1_inbounds() | ||
r = 0 | ||
@inbounds begin | ||
@boundscheck r += 1 | ||
end | ||
return r | ||
end | ||
|
||
function A1() | ||
r = 0 | ||
@boundscheck r += 1 | ||
return r | ||
end | ||
|
||
@test A1() == 1 | ||
@test A1_inbounds() == 0 | ||
|
||
# test for boundscheck block elision one layer deep | ||
function A2_inbounds() | ||
@inbounds r = A1()+1 | ||
return r | ||
end | ||
|
||
function A2() | ||
r = A1()+1 | ||
return r | ||
end | ||
|
||
@test A2() == 2 | ||
@test A2_inbounds() == 1 | ||
|
||
# test boundscheck NOT elided two layers deep | ||
# C() = (y=0; @boundscheck y += A1()+1; return y) | ||
B() = A1() + 1 | ||
|
||
function A3_inbounds() | ||
@inbounds r = B()+1 | ||
return r | ||
end | ||
|
||
function A3() | ||
r = B()+1 | ||
return r | ||
end | ||
|
||
@test A3() == 3 | ||
@test A3_inbounds() == 3 | ||
|
||
end |
This file contains 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