Skip to content

Commit

Permalink
remove more dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed May 26, 2022
1 parent 651d82c commit 9f35f74
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 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 <[email protected]>"]
version = "0.12.112"
version = "0.12.113"

[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 @@ -463,8 +463,8 @@ function thread_one_loops_expr(
push!(loopboundexpr.args, looprange)
push!(lastboundexpr.args, lastrange)
else
loop_boundary!(loopboundexpr, ls, loop, true)
loop_boundary!(lastboundexpr, ls, loop, true)
loop_boundary!(loopboundexpr, loop, true)
loop_boundary!(lastboundexpr, loop, true)
end
end
avxcall_args = Expr(:tuple, lastboundexpr, Symbol("#vargs#"))
Expand Down Expand Up @@ -676,8 +676,8 @@ function thread_two_loops_expr(
push!(loopboundexpr.args, looprange2)
push!(lastboundexpr.args, lastrange2)
else
loop_boundary!(loopboundexpr, ls, loop, true)
loop_boundary!(lastboundexpr, ls, loop, true)
loop_boundary!(loopboundexpr, loop, true)
loop_boundary!(lastboundexpr, loop, true)
end
end
avxcall_args = Expr(:tuple, lastboundexpr, Symbol("#vargs#"))
Expand Down
1 change: 0 additions & 1 deletion src/codegen/split_loops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ function lower_and_split_loops(ls::LoopSet, inline::Int)
order_2, unrolled_2, tiled_2, vectorized_2, U_2, T_2, cost_2, shouldinline_2 =
choose_order_cost(ls_2)
# U_1 = T_1 = U_2 = T_2 = 2
# return ls_1, ls_2
if cost_1 + cost_2 + looplenpen * (looplengthprod(ls_1) + looplengthprod(ls_2))
muladd(0.9, cost_fused, ls_looplen)
ls_2_lowered = if length(remaining_ops) > 1
Expand Down
12 changes: 7 additions & 5 deletions src/condense_loopset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ function OperationStruct!(
ls::LoopSet,
op::Operation,
)
instr = instruction(op)
ld = loopdeps_uint(ls, op)
rd = reduceddeps_uint(ls, op)
cd = childdeps_uint(ls, op)
Expand All @@ -241,7 +240,7 @@ end
@inline zerorangestart(r::ArrayInterface.OptionallyStaticUnitRange{StaticInt{1}}) =
CloseOpen(maybestaticlast(r))

function loop_boundary!(q::Expr, ls::LoopSet, loop::Loop, shouldindbyind::Bool)
function loop_boundary!(q::Expr, loop::Loop, shouldindbyind::Bool)
if isstaticloop(loop) || loop.rangesym === Symbol("")
call = Expr(:call, :(:))
f = gethint(first(loop))
Expand All @@ -265,7 +264,7 @@ end
function loop_boundaries(ls::LoopSet, shouldindbyind::Vector{Bool})
lbd = Expr(:tuple)
for (ibi, loop) zip(shouldindbyind, ls.loops)
loop_boundary!(lbd, ls, loop, ibi)
loop_boundary!(lbd, loop, ibi)
end
lbd
end
Expand Down Expand Up @@ -770,8 +769,11 @@ function generate_call_types(
ops = operations(ls)
for op ops
instr::Instruction = instruction(op)
if ((isconstant(op) && (instr == LOOPCONSTANT)) && (!roots[identifier(op)]))
instr = op.instruction = DROPPEDCONSTANT
if (!roots[identifier(op)])
if (isconstant(op) && (instr == LOOPCONSTANT)) || !isconstant(op)
instr = op.instruction = DROPPEDCONSTANT
op.node_type = constant
end

This comment has been minimized.

Copy link
@chriselrod

chriselrod May 26, 2022

Author Member

@brenhinkeller this is the part that made a difference.

This comment has been minimized.

Copy link
@chriselrod

chriselrod May 26, 2022

Author Member

This drops dead code, so that it's not used later in the cost calculations.

lower_and_split_loops generates alternative split loops -- and doesn't add the dead code to them -- and compares them with the original fused loop.
Having the dead code added to the cost of the fused loop, but not to the split loops, can cause it to split when it should not.

Splitting reorders the instructions, resulting in a wrong answer in reverse!.
Also, when you pass an unroll argument, LV does not try to split loops. That's why that made a difference.

This comment has been minimized.

Copy link
@brenhinkeller

brenhinkeller May 26, 2022

Contributor

Oh cool! I guess that makes sense about unroll then!

end
push!(operation_descriptions.args, QuoteNode(instr.mod))
push!(operation_descriptions.args, QuoteNode(instr.instr))
Expand Down
2 changes: 1 addition & 1 deletion src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ function _precompile_()
Tuple{StaticInt{1},Int},
},
) # time: 0.001156726
Base.precompile(Tuple{typeof(loop_boundary!),Expr,LoopSet,Loop,Bool}) # time: 0.001152516
Base.precompile(Tuple{typeof(loop_boundary!),Expr,Loop,Bool}) # time: 0.001152516
Base.precompile(Tuple{typeof(maybestatic!),Expr}) # time: 0.001151616
Base.precompile(Tuple{typeof(tuple_expr),typeof(identity),Vector{Tuple{Int,NumberType}}}) # time: 0.001148223
Base.precompile(
Expand Down

2 comments on commit 9f35f74

@chriselrod
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/61069

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.113 -m "<description of version>" 9f35f742d0652a1849c4a58e5a3c2c332bcd0641
git push origin v0.12.113

Please sign in to comment.