aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_ssa_opt.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-09-08 10:20:07 +0200
committerBjörn Gustavsson <[email protected]>2018-09-12 14:19:06 +0200
commitb3b195fd104e7052fe31becbab43fccb652f2d0a (patch)
treeae513028be67e25924da86d1bebdf7cb5b90ac96 /lib/compiler/src/beam_ssa_opt.erl
parent4edd266876f2383ccc33b91a3bbe8550279368f5 (diff)
downloadotp-b3b195fd104e7052fe31becbab43fccb652f2d0a.tar.gz
otp-b3b195fd104e7052fe31becbab43fccb652f2d0a.tar.bz2
otp-b3b195fd104e7052fe31becbab43fccb652f2d0a.zip
beam_ssa_opt: Slightly optimize performance of live optimization
Phi nodes with only literals are fairly common, so it's worthwhile to optimize this case.
Diffstat (limited to 'lib/compiler/src/beam_ssa_opt.erl')
-rw-r--r--lib/compiler/src/beam_ssa_opt.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl
index 0bb4a204a2..6d94c38685 100644
--- a/lib/compiler/src/beam_ssa_opt.erl
+++ b/lib/compiler/src/beam_ssa_opt.erl
@@ -820,11 +820,16 @@ live_opt_phis(Is, L, Live0, LiveMap0) ->
LiveMap;
[_|_] ->
PhiArgs = append([Args || #b_set{args=Args} <- Phis]),
- PhiVars = [{P,V} || {#b_var{name=V},P} <- PhiArgs],
- PhiLive0 = rel2fam(PhiVars),
- PhiLive = [{{L,P},gb_sets:union(gb_sets:from_list(Vs), Live0)} ||
- {P,Vs} <- PhiLive0],
- maps:merge(LiveMap, maps:from_list(PhiLive))
+ case [{P,V} || {#b_var{name=V},P} <- PhiArgs] of
+ [_|_]=PhiVars ->
+ PhiLive0 = rel2fam(PhiVars),
+ PhiLive = [{{L,P},gb_sets:union(gb_sets:from_list(Vs), Live0)} ||
+ {P,Vs} <- PhiLive0],
+ maps:merge(LiveMap, maps:from_list(PhiLive));
+ [] ->
+ %% There were only literals in the phi node(s).
+ LiveMap
+ end
end.
live_opt_blk(#b_blk{is=Is0,last=Last}=Blk, Live0) ->