aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-01-29 20:35:45 +0100
committerBjörn Gustavsson <[email protected]>2019-02-01 12:44:32 +0100
commitc86c4dd18da287e439770c47fa384d438c134f12 (patch)
tree0508d346806c48ad1f43a78e4be67d5d2e8a606b /lib
parent9a190cae9bd7213ff018e17a909efbab04a14a8c (diff)
downloadotp-c86c4dd18da287e439770c47fa384d438c134f12.tar.gz
otp-c86c4dd18da287e439770c47fa384d438c134f12.tar.bz2
otp-c86c4dd18da287e439770c47fa384d438c134f12.zip
Speed up beam_ssa_dead when there are many sequential blocks
beam_ssa_dead could be very slow if there were many blocks connected with unconditional branches (for example, if a block had contained many `call` instructions and been split by ssa_opt_split_blocks). It turns out that `comb_get_sw/3` does an unnecessary (and perhaps incorrect) recursive call to itself when the terminator for the block is an unconditional branch. Removing the recursive call does not disable any optimizations, but will be much faster if there are many blocks connected with unconditional branches. Reported-by: Michał Muskała
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/beam_ssa_dead.erl6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/compiler/src/beam_ssa_dead.erl b/lib/compiler/src/beam_ssa_dead.erl
index 09b29025c6..db82aaa8e6 100644
--- a/lib/compiler/src/beam_ssa_dead.erl
+++ b/lib/compiler/src/beam_ssa_dead.erl
@@ -850,7 +850,7 @@ combine_eqs_1([], St) -> St.
comb_get_sw(L, Blocks) ->
comb_get_sw(L, true, Blocks).
-comb_get_sw(L, Safe0, #st{bs=Blocks,skippable=Skippable}=St) ->
+comb_get_sw(L, Safe0, #st{bs=Blocks,skippable=Skippable}) ->
#b_blk{is=Is,last=Last} = maps:get(L, Blocks),
Safe1 = Safe0 andalso is_map_key(L, Skippable),
case Last of
@@ -865,8 +865,8 @@ comb_get_sw(L, Safe0, #st{bs=Blocks,skippable=Skippable}=St) ->
{#b_set{},_} ->
none
end;
- #b_br{bool=#b_literal{val=true},succ=Succ} ->
- comb_get_sw(Succ, Safe1, St);
+ #b_br{} ->
+ none;
#b_switch{arg=#b_var{}=Arg,fail=Fail,list=List} ->
{none,Safe} = comb_is(Is, none, Safe1),
{Safe,Arg,L,Fail,List}