Skip to content

Commit 591023e

Browse files
authored
Merge pull request #181 from DilumAluthge/dpa/avx-coverage
Include the original `LineNumberNode`s from the original expression in the final expression
2 parents 6987acf + 8b1301b commit 591023e

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.9.12"
4+
version = "0.9.13"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/LoopVectorization.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ using VectorizationBase: REGISTER_SIZE, REGISTER_COUNT, data,
1717

1818
using IfElse: ifelse
1919

20-
# missing: stridedpointer_for_broadcast, noalias!, gepbyte,
21-
# using SIMDPirates: VECTOR_SYMBOLS, evadd, evsub, evmul, evfdiv, vrange,
20+
# missing: stridedpointer_for_broadcast, noalias!, gepbyte,
21+
# using SIMDPirates: VECTOR_SYMBOLS, evadd, evsub, evmul, evfdiv, vrange,
2222
# reduced_add, reduced_prod, reduce_to_add, reduced_max, reduced_min, vsum, vprod, vmaximum, vminimum,
2323
# sizeequivalentfloat, sizeequivalentint, vadd!, vsub!, vmul!, vfdiv!, vfmadd!, vfnmadd!, vfmsub!, vfnmsub!,
2424
# vfmadd231, vfmsub231, vfnmadd231, vfnmsub231, sizeequivalentfloat, sizeequivalentint, #prefetch,
@@ -67,6 +67,7 @@ include("add_compute.jl")
6767
include("add_constants.jl")
6868
include("add_ifelse.jl")
6969
include("determinestrategy.jl")
70+
include("line_number_nodes.jl")
7071
include("loopstartstopmanager.jl")
7172
include("lower_compute.jl")
7273
include("lower_constant.jl")

src/condense_loopset.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ end
210210
# Try to condense in type stable manner
211211
function generate_call(ls::LoopSet, inline_unroll::NTuple{3,Int8}, debug::Bool = false)
212212
operation_descriptions = Expr(:curly, :Tuple)
213-
varnames = Symbol[]; ids = Vector{Int}(undef, length(operations(ls)))
213+
varnames = Symbol[]; ids = Vector{Int}(undef, length(operations(ls)))
214214
for op operations(ls)
215215
instr = instruction(op)
216216
push!(operation_descriptions.args, QuoteNode(instr.mod))
@@ -315,7 +315,7 @@ function setup_call_inline(ls::LoopSet, inline::Int8 = zero(Int8), U::Int8 = zer
315315
end
316316
function setup_call_debug(ls::LoopSet)
317317
# avx_loopset(instr, ops, arf, AM, LB, vargs)
318-
318+
319319
pushpreamble!(ls, generate_call(ls, (zero(Int8),zero(Int8),zero(Int8)), true))
320320
Expr(:block, ls.prepreamble, ls.preamble)
321321
end
@@ -325,8 +325,11 @@ function setup_call(ls::LoopSet, q = nothing, inline::Int8 = zero(Int8), check_e
325325
# the generated function must be inlined into the initial loop preamble for performance reasons.
326326
# Creating an anonymous function and calling it also achieves the outlining, while still
327327
# inlining the generated function into the loop preamble.
328+
lnns = extract_all_lnns(q)
328329
call = setup_call_inline(ls, inline, u₁, u₂)
329330
call = check_empty ? check_if_empty(ls, call) : call
330331
isnothing(q) && return Expr(:block, ls.prepreamble, call)
331-
Expr(:block, ls.prepreamble, Expr(:if, check_args_call(ls), call, make_crashy(make_fast(q))))
332+
result = Expr(:block, ls.prepreamble, Expr(:if, check_args_call(ls), call, make_crashy(make_fast(q))))
333+
prepend_lnns!(result, lnns)
334+
return result
332335
end

src/line_number_nodes.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function extract_all_lnns(x)
2+
lnns = Vector{LineNumberNode}(undef, 0)
3+
extract_all_lnns!(lnns, x)
4+
return lnns
5+
end
6+
7+
function extract_all_lnns!(lnns::AbstractVector{<:LineNumberNode}, lnn::LineNumberNode)
8+
push!(lnns, lnn)
9+
return lnns
10+
end
11+
function extract_all_lnns!(lnns::AbstractVector{<:LineNumberNode}, ex::Expr)
12+
for arg in ex.args
13+
extract_all_lnns!(lnns::AbstractVector{<:LineNumberNode}, arg)
14+
end
15+
return lnns
16+
end
17+
function extract_all_lnns!(lnns::AbstractVector{<:LineNumberNode}, ::Any)
18+
return lnns
19+
end
20+
21+
function prepend_lnns!(ex::Expr, lnns::AbstractVector{<:LineNumberNode})
22+
return prepend_lnns!(ex, lnns, Val(ex.head))
23+
end
24+
function prepend_lnns!(ex::Expr, lnns::AbstractVector{<:LineNumberNode}, ::Val{:block})
25+
for lnn in lnns
26+
pushfirst!(ex.args, Expr(:block, lnn, :(nothing)))
27+
end
28+
return ex
29+
end

0 commit comments

Comments
 (0)