Skip to content

Commit 40e2334

Browse files
authored
Merge pull request #10252 from bjorng/bjorn/compiler/fix-bottlenecks/OTP-19797
Fix two bottlenecks in the compiler
2 parents f736bde + b25b91a commit 40e2334

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/compiler/src/beam_core_to_ssa.erl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,8 +2599,14 @@ select_val_cg(Type, R, Vls, Tf, Vf, Sis, St0) ->
25992599
{TypeIs++[#b_switch{arg=R,fail=Vf,list=Vls}|Sis],St1}
26002600
end.
26012601

2602-
combine([{Is,Vs1},{Is,Vs2}|Vis]) -> combine([{Is,Vs1 ++ Vs2}|Vis]);
2603-
combine([V|Vis]) -> [V|combine(Vis)];
2602+
2603+
combine([V|Vis0]) ->
2604+
case {V, combine(Vis0)} of
2605+
{{Is,Vs1}, [{Is,Vs2}|Vis]} ->
2606+
[{Is,Vs1 ++ Vs2}|Vis];
2607+
{_,Vis} ->
2608+
[V|Vis]
2609+
end;
26042610
combine([]) -> [].
26052611

26062612
select_labels([{Is,Vs}|Vis], St0, Vls, Sis) ->

lib/stdlib/src/erl_lint.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,7 +3988,7 @@ icrt_export([{V,{{export,_},_,_}}|Vs0], [{V,{{export,_}=S0,_,As}}|Vt],
39883988
%% V was an exported variable and has been used in an expression in at least
39893989
%% one clause. Its state needs to be merged from all clauses to silence any
39903990
%% exported var warning already emitted.
3991-
{VVs,Vs} = lists:partition(fun ({K,_}) -> K =:= V end, Vs0),
3991+
{VVs,Vs} = lists:splitwith(fun ({K,_}) -> K =:= V end, Vs0),
39923992
S = foldl(fun ({_,{S1,_,_}}, AccS) -> merge_state(AccS, S1) end, S0, VVs),
39933993
icrt_export(Vs, Vt, In, I, [{V,{S,used,As}}|Acc]);
39943994
icrt_export([{V,_}|Vs0], [{V,{_,_,As}}|Vt], In, I, Acc) ->
@@ -4003,7 +4003,7 @@ icrt_export([{V1,_}|_]=Vs, [{V2,_}|Vt], In, I, Acc) when V1 > V2 ->
40034003
icrt_export(Vs, Vt, In, I, Acc);
40044004
icrt_export([{V,_}|_]=Vs0, Vt, In, I, Acc) ->
40054005
%% V is a new variable.
4006-
{VVs,Vs} = lists:partition(fun ({K,_}) -> K =:= V end, Vs0),
4006+
{VVs,Vs} = lists:splitwith(fun ({K,_}) -> K =:= V end, Vs0),
40074007
F = fun ({_,{S,U,As}}, {AccI,AccS0,AccAs0}) ->
40084008
AccS = case {S,AccS0} of
40094009
{{unsafe,_},{unsafe,_}} ->

0 commit comments

Comments
 (0)