Skip to content

Commit

Permalink
Remove broken register passing optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Jan 8, 2024
1 parent 3fbe248 commit eebb453
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 92 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LoopVectorization"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <elrodc@gmail.com>"]
version = "0.12.168"
version = "0.12.169"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/lower_threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ function thread_one_loops_expr(
$AM,
$LPSYM,
Val(typeof(var"#avx#call#args#")),
flatten_to_tuple(var"#avx#call#args#")...
var"#avx#call#args#"...
))
update_return_values = if length(ls.outer_reductions) > 0
retv = loopset_return_value(ls, Val(false))
Expand Down Expand Up @@ -555,7 +555,7 @@ function thread_one_loops_expr(
$AM,
$LPSYM,
StaticType{typeof(var"##lbvargs#to_launch##")}(),
flatten_to_tuple(var"##lbvargs#to_launch##"),
var"##lbvargs#to_launch##",
var"#thread#id#"
)

Expand Down Expand Up @@ -744,7 +744,7 @@ function thread_two_loops_expr(
$AM,
$LPSYM,
Val(typeof(var"#avx#call#args#")),
flatten_to_tuple(var"#avx#call#args#")...
var"#avx#call#args#"...
))
update_return_values = if length(ls.outer_reductions) > 0
retv = loopset_return_value(ls, Val(false))
Expand Down Expand Up @@ -867,7 +867,7 @@ function thread_two_loops_expr(
$AM,
$LPSYM,
StaticType{typeof(var"##lbvargs#to_launch##")}(),
flatten_to_tuple(var"##lbvargs#to_launch##"),
var"##lbvargs#to_launch##",
var"#thread#id#"
)
var"#thread#mask#" >>>= var"#trailzing#zeros#"
Expand Down
69 changes: 2 additions & 67 deletions src/condense_loopset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,6 @@
Base.:|(u::Unsigned, it::IndexType) = u | UInt8(it)
Base.:(==)(u::Unsigned, it::IndexType) = (u % UInt8) == UInt8(it)

function _append_fields!(t::Expr, body::Expr, sym::Symbol, ::Type{T}) where {T}
for f 1:fieldcount(T)
TF = fieldtype(T, f)
Base.issingletontype(TF) && continue
gfcall = Expr(:call, getfield, sym, f)
if fieldcount(TF) 0
push!(t.args, gfcall)
elseif TF <: DataType
push!(t.args, Expr(:call, Expr(:curly, lv(:StaticType), gfcall)))
else
newsym = gensym(sym)
push!(body.args, Expr(:(=), newsym, gfcall))
_append_fields!(t, body, newsym, TF)
end
end
return nothing
end
@generated function flatten_to_tuple(r::T) where {T}
body = Expr(:block, Expr(:meta, :inline))
t = Expr(:tuple)
if Base.issingletontype(T)
nothing
elseif fieldcount(T) 0
push!(t.args, :r)
elseif T <: DataType
push!(t.args, Expr(:call, Expr(:curly, lv(:StaticType), :r)))
else
_append_fields!(t, body, :r, T)
end
push!(body.args, t)
body
end
function rebuild_fields(offset::Int, ::Type{T}) where {T}
call = (T <: Tuple) ? Expr(:tuple) : Expr(:new, T)
for f 1:fieldcount(T)
TF = fieldtype(T, f)
if Base.issingletontype(TF)
push!(call.args, TF.instance)
elseif fieldcount(TF) 0
push!(call.args, Expr(:call, getfield, :t, (offset += 1)))
elseif TF <: DataType
push!(
call.args,
Expr(:call, lv(:gettype), Expr(:call, getfield, :t, (offset += 1)))
)
else
arg, offset = rebuild_fields(offset, TF)
push!(call.args, arg)
end
end
return call, offset
end
@generated function reassemble_tuple(::Type{T}, t::Tuple) where {T}
if Base.issingletontype(T)
return T.instance
elseif fieldcount(T) 0
call = Expr(:call, getfield, :t, 1)
elseif T <: DataType
call = Expr(:call, lv(:gettype), Expr(:call, getfield, :t, 1))
else
call, _ = rebuild_fields(0, T)
end
Expr(:block, Expr(:meta, :inline), call)
end

"""
ArrayRefStruct
Expand Down Expand Up @@ -893,9 +828,9 @@ function generate_call_types(
)
)
if manyarg
push!(q.args, Expr(:call, lv(:flatten_to_tuple), vargsym))
push!(q.args, vargsym)
else
push!(q.args, Expr(:(...), Expr(:call, lv(:flatten_to_tuple), vargsym)))
push!(q.args, Expr(:(...), vargsym))
end
Expr(:block, Expr(:(=), vargsym, Expr(:tuple, lbarg, extra_args)))
end
Expand Down
22 changes: 2 additions & 20 deletions src/reconstruct_loopset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ Execute an `@turbo` block. The block's code is represented via the arguments:
::Val{var"#AM#"},
::Val{var"#LPSYM#"},
::Val{Tuple{var"#LB#",var"#V#"}},
var"#flattened#var#arguments#"::Vararg{Any,var"#num#vargs#"}
var"#lv#tuple#args#"::Vararg{Any,var"#num#vargs#"}
) where {
var"#UNROLL#",
var"#OPS#",
Expand All @@ -1132,15 +1132,6 @@ Execute an `@turbo` block. The block's code is represented via the arguments:
var"#V#".parameters,
var"#UNROLL#"
)
pushfirst!(
ls.preamble.args,
:(
var"#lv#tuple#args#" = reassemble_tuple(
Tuple{var"#LB#",var"#V#"},
var"#flattened#var#arguments#"
)
)
)
post = hoist_constant_memory_accesses!(ls)
# q = @show(avx_body(ls, var"#UNROLL#")); post === ls.preamble ? q : Expr(:block, q, post)
q = if (var"#UNROLL#"[10] > 1) && length(var"#LPSYM#") == length(ls.loops)
Expand Down Expand Up @@ -1171,7 +1162,7 @@ end
::Val{var"#AM#"},
::Val{var"#LPSYM#"},
::Val{Tuple{var"#LB#",var"#V#"}},
var"#flattened#var#arguments#"::Tuple{Vararg{Any,var"#num#vargs#"}}
var"#lv#tuple#args#"::Tuple{Vararg{Any,var"#num#vargs#"}}
) where {
var"#UNROLL#",
var"#OPS#",
Expand All @@ -1192,15 +1183,6 @@ end
var"#V#".parameters,
var"#UNROLL#"
)
pushfirst!(
ls.preamble.args,
:(
var"#lv#tuple#args#" = reassemble_tuple(
Tuple{var"#LB#",var"#V#"},
var"#flattened#var#arguments#"
)
)
)
post = hoist_constant_memory_accesses!(ls)
# q = @show(avx_body(ls, var"#UNROLL#")); post === ls.preamble ? q : Expr(:block, q, post)
q = if (var"#UNROLL#"[10] > 1) && length(var"#LPSYM#") == length(ls.loops)
Expand Down

0 comments on commit eebb453

Please sign in to comment.