aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-10-07 18:27:04 +0200
committerBjörn-Egil Dahlberg <[email protected]>2014-10-07 18:30:29 +0200
commit09423921afff7a9dd2730788a88b0dccb20cd174 (patch)
treee32cfbda9c70bf2b50090525f1b858b09a971c85 /lib/compiler
parent891a1ed42acf41fc855f6cb5db9c122a28078c8b (diff)
downloadotp-09423921afff7a9dd2730788a88b0dccb20cd174.tar.gz
otp-09423921afff7a9dd2730788a88b0dccb20cd174.tar.bz2
otp-09423921afff7a9dd2730788a88b0dccb20cd174.zip
compiler: Type is_nonempty_list optimization
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/beam_type.erl10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_type.erl b/lib/compiler/src/beam_type.erl
index 4459c92df5..cdddad4153 100644
--- a/lib/compiler/src/beam_type.erl
+++ b/lib/compiler/src/beam_type.erl
@@ -113,6 +113,13 @@ simplify_basic_1([{test,is_map,_,[R]}=I|Is], Ts0, Acc) ->
Ts = update(I, Ts0),
simplify_basic_1(Is, Ts, [I|Acc])
end;
+simplify_basic_1([{test,is_nonempty_list,_,[R]}=I|Is], Ts0, Acc) ->
+ case tdb_find(R, Ts0) of
+ nonempty_list -> simplify_basic_1(Is, Ts0, Acc);
+ _Other ->
+ Ts = update(I, Ts0),
+ simplify_basic_1(Is, Ts, [I|Acc])
+ end;
simplify_basic_1([{test,is_eq_exact,Fail,[R,{atom,_}=Atom]}=I|Is0], Ts0, Acc0) ->
Acc = case tdb_find(R, Ts0) of
{atom,_}=Atom -> Acc0;
@@ -411,6 +418,8 @@ update({test,test_arity,_Fail,[Src,Arity]}, Ts0) ->
tdb_update([{Src,{tuple,Arity,[]}}], Ts0);
update({test,is_map,_Fail,[Src]}, Ts0) ->
tdb_update([{Src,map}], Ts0);
+update({test,is_nonempty_list,_Fail,[Src]}, Ts0) ->
+ tdb_update([{Src,nonempty_list}], Ts0);
update({test,is_eq_exact,_,[Reg,{atom,_}=Atom]}, Ts) ->
case tdb_find(Reg, Ts) of
error ->
@@ -720,6 +729,7 @@ merge_type_info(NewType, _) ->
NewType.
verify_type(map) -> ok;
+verify_type(nonempty_list) -> ok;
verify_type({tuple,Sz,[]}) when is_integer(Sz) -> ok;
verify_type({tuple,Sz,[_]}) when is_integer(Sz) -> ok;
verify_type({tuple_element,_,_}) -> ok;