Skip to content

Commit

Permalink
make sure that the loop doesn't unroll without the pragma
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Mar 15, 2019
1 parent 302abbe commit 1adbff5
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion test/llvmpasses/loopinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,46 @@ end

# Example from a GPU kernel where we want to unroll the outer loop
# and the inner loop is a boundschecked single iteration loop.
# The `@show` is used to bloat the loop and `FINAL-COUNT-10:` seems
# not to be working so we duplicate the checks.
# CHECK-LABEL: @julia_loop_unroll2
# LOWER-LABEL: @julia_loop_unroll2
# FINAL-LABEL: @julia_loop_unroll2
@eval function loop_unroll2(J, I)
for i in 1:10
for j in J
1 <= j <= I && continue
@show (i,j)
iteration(i)
end
$(Expr(:loopinfo, (Symbol("llvm.loop.unroll.full"),)))
# CHECK: call void @julia.loopinfo_marker(), {{.*}}, !julia.loopinfo [[LOOPINFO4:![0-9]+]]
# LOWER-NOT: call void @julia.loopinfo_marker()
# LOWER: br {{.*}}, !llvm.loop [[LOOPID4:![0-9]+]]
# FINAL-COUNT-10: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL: call i64 @julia_iteration
# FINAL-NOT: call i64 @julia_iteration
end
end

# FINAL-LABEL: @julia_notunroll
function notunroll(J, I)
for i in 1:10
for j in J
1 <= j <= I && continue
@show (i,j)
iteration(i)
# FINAL: call i64 @julia_iteration
# FINAL-NOT: call i64 @julia_iteration
end
end
end

Expand Down Expand Up @@ -132,3 +158,4 @@ emit(simdf, Vector{Float64})
emit(simdf2, Vector{Float64})
emit(loop_unroll, Int64)
emit(loop_unroll2, Int64, Int64)
emit(notunroll, Int64, Int64)

0 comments on commit 1adbff5

Please sign in to comment.