diff options
author | Björn Gustavsson <[email protected]> | 2019-02-22 11:29:48 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-02-22 11:29:48 +0100 |
commit | 3cec819e8eb3cd992242f58aae22d06feef070d6 (patch) | |
tree | 4c0c99d82b84ddde7c11f6762b17571756e61f94 /lib/compiler/src/beam_ssa_type.erl | |
parent | 305204ffb816a93885e4919b0cd691fcaa8ed440 (diff) | |
parent | 5239eb0c62a96fb6b02c182a6786049e9782b123 (diff) | |
download | otp-3cec819e8eb3cd992242f58aae22d06feef070d6.tar.gz otp-3cec819e8eb3cd992242f58aae22d06feef070d6.tar.bz2 otp-3cec819e8eb3cd992242f58aae22d06feef070d6.zip |
Merge branch 'bjorn/compiler/fix-name-capture'
* bjorn/compiler/fix-name-capture:
sys_core_fold: Remove an unsafe optimization
beam_ssa_type: Optimize setelement with partially constant arguments
beam_ssa_opt: Do local CSE of get_tuple_element instructions
Diffstat (limited to 'lib/compiler/src/beam_ssa_type.erl')
-rw-r--r-- | lib/compiler/src/beam_ssa_type.erl | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl index 5fbb679c6f..c040fb2dde 100644 --- a/lib/compiler/src/beam_ssa_type.erl +++ b/lib/compiler/src/beam_ssa_type.erl @@ -24,7 +24,7 @@ -include("beam_ssa_opt.hrl"). -import(lists, [all/2,any/2,droplast/1,foldl/3,last/1,member/2, keyfind/3,partition/2,reverse/1,reverse/2, - seq/2,sort/1]). + seq/2,sort/1,split/2]). -define(UNICODE_INT, #t_integer{elements={0,16#10FFFF}}). @@ -358,6 +358,17 @@ simplify_call(I) -> I. %% Simplify a remote call to a pure BIF. simplify_remote_call(erlang, '++', [#b_literal{val=[]},Tl], _I) -> Tl; +simplify_remote_call(erlang, setelement, + [#b_literal{val=Pos}, + #b_literal{val=Tuple}, + #b_var{}=Value], I) + when is_integer(Pos), 1 =< Pos, Pos =< tuple_size(Tuple) -> + %% Position is a literal integer and the shape of the + %% tuple is known. + Els0 = [#b_literal{val=El} || El <- tuple_to_list(Tuple)], + {Bef,[_|Aft]} = split(Pos - 1, Els0), + Els = Bef ++ [Value|Aft], + I#b_set{op=put_tuple,args=Els}; simplify_remote_call(Mod, Name, Args0, I) -> case make_literal_list(Args0) of none -> |