Skip to content

Commit a5f5e8a

Browse files
yhlsvchuravy
authored andcommitted
Remove dead blocks as determined by reachability instead of number of predecessors
For now, just construct the domtree when we make an `IncrementalCompact` rather than try to update it (the domtree) incrementally.
1 parent 8731615 commit a5f5e8a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

base/compiler/ssair/ir.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,9 @@ mutable struct IncrementalCompact
566566
if allow_cfg_transforms
567567
bb_rename = Vector{Int}(undef, length(blocks))
568568
cur_bb = 1
569+
domtree = construct_domtree(blocks)
569570
for i = 1:length(bb_rename)
570-
if i != 1 && length(blocks[i].preds) == 0
571+
if bb_unreachable(domtree, i)
571572
bb_rename[i] = -1
572573
else
573574
bb_rename[i] = cur_bb
@@ -1219,8 +1220,8 @@ function iterate(compact::IncrementalCompact, (idx, active_bb)::Tuple{Int, Int}=
12191220
resize!(compact, old_result_idx)
12201221
end
12211222
bb = compact.ir.cfg.blocks[active_bb]
1222-
if compact.cfg_transforms_enabled && active_bb > 1 && active_bb <= length(compact.bb_rename_succ) && length(bb.preds) == 0
1223-
# No predecessors, kill the entire block.
1223+
if compact.cfg_transforms_enabled && active_bb > 1 && active_bb <= length(compact.bb_rename_succ) && compact.bb_rename_succ[active_bb] == -1
1224+
# Dead block, so kill the entire block.
12241225
compact.idx = last(bb.stmts)
12251226
# Pop any remaining insertion nodes
12261227
while compact.new_nodes_idx <= length(compact.perm)

0 commit comments

Comments
 (0)