diff options
author | Björn Gustavsson <[email protected]> | 2017-10-23 12:40:47 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-10-23 12:40:47 +0200 |
commit | db67b2c3d1198b2093cb9add3aa55c59bb368ab5 (patch) | |
tree | a5dc718fae196ff613f828c0f283327db6952d95 /lib/compiler/src/v3_codegen.erl | |
parent | e7e17c75b38392f6722a00df45581b104e2829e2 (diff) | |
parent | 19a1af93458ec7a4a252671603d74971f4dec969 (diff) | |
download | otp-db67b2c3d1198b2093cb9add3aa55c59bb368ab5.tar.gz otp-db67b2c3d1198b2093cb9add3aa55c59bb368ab5.tar.bz2 otp-db67b2c3d1198b2093cb9add3aa55c59bb368ab5.zip |
Merge branch 'bjorn/compiler/match-literals'
* bjorn/compiler/match-literals:
Optimize instructions for comparing a register with a literal
Optimize matching of literals for single-valued types
Diffstat (limited to 'lib/compiler/src/v3_codegen.erl')
-rw-r--r-- | lib/compiler/src/v3_codegen.erl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/compiler/src/v3_codegen.erl b/lib/compiler/src/v3_codegen.erl index e705aefb96..ee5bafbc5c 100644 --- a/lib/compiler/src/v3_codegen.erl +++ b/lib/compiler/src/v3_codegen.erl @@ -654,6 +654,8 @@ select_cg(#l{ke={type_clause,bin_end,[S]}}, {var,V}, Tf, _Vf, Bef, St) -> select_bin_end(S, V, Tf, Bef, St); select_cg(#l{ke={type_clause,map,S}}, {var,V}, Tf, Vf, Bef, St) -> select_map(S, V, Tf, Vf, Bef, St); +select_cg(#l{ke={type_clause,literal,S}}, {var,V}, Tf, Vf, Bef, St) -> + select_literal(S, V, Tf, Vf, Bef, St); select_cg(#l{ke={type_clause,Type,Scs}}, {var,V}, Tf, Vf, Bef, St0) -> {Vis,{Aft,St1}} = mapfoldl(fun (S, {Int,Sta}) -> @@ -695,6 +697,15 @@ add_vls([V|Vs], Lbl, Acc) -> add_vls(Vs, Lbl, [V, {f,Lbl}|Acc]); add_vls([], _, Acc) -> Acc. +select_literal(S, V, Tf, Vf, Bef, St) -> + Reg = fetch_var(V, Bef), + F = fun(ValClause, Fail, St0) -> + {Val,Is,Aft,St1} = select_val(ValClause, V, Vf, Bef, St0), + Test = {test,is_eq_exact,{f,Fail},[Reg,{literal,Val}]}, + {[Test|Is],Aft,St1} + end, + match_fmf(F, Tf, St, S). + select_cons(#l{ke={val_clause,{cons,Es},B},i=I,vdb=Vdb}, V, Tf, Vf, Bef, St0) -> {Eis,Int,St1} = select_extract_cons(V, Es, I, Vdb, Bef, St0), {Bis,Aft,St2} = match_cg(B, Vf, Int, St1), |