aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_peep.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-09-28 11:42:08 +0200
committerBjörn Gustavsson <[email protected]>2015-09-28 11:42:08 +0200
commit7ca56726d7b3c8e679273950978f9f1816d4b277 (patch)
tree6954a4a604adae35c95db80390dc43c7fd1fc3bc /lib/compiler/src/beam_peep.erl
parent51750b8bd4d4eb08aacd2ad2bb0ac13fd6d09746 (diff)
parent464ca2f8049feec6453d2d9a327f996662978e51 (diff)
downloadotp-7ca56726d7b3c8e679273950978f9f1816d4b277.tar.gz
otp-7ca56726d7b3c8e679273950978f9f1816d4b277.tar.bz2
otp-7ca56726d7b3c8e679273950978f9f1816d4b277.zip
Merge branch 'bjorn/compiler/misc'
* bjorn/compiler/misc: Move select_val optimization from beam_clean to beam_peep beam_type: Improve optimizations by keeping track of booleans beam_type: Improve optimization by keeping track of integers beam_type: Remove unused clause beam_type: Fix forgotten change of internal representation beam_dead: Improve optimization of literal binary matching beam_dead: Optimize select_val instructions Move out bit syntax optimizations from beam_block sys_core_fold: Extend the list of BIFs that return integers v3_codegen: Optimize matching of the final size-less binary segment Regain full coverage of beam_block
Diffstat (limited to 'lib/compiler/src/beam_peep.erl')
-rw-r--r--lib/compiler/src/beam_peep.erl16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_peep.erl b/lib/compiler/src/beam_peep.erl
index 75be86b83f..0c1abfe6a0 100644
--- a/lib/compiler/src/beam_peep.erl
+++ b/lib/compiler/src/beam_peep.erl
@@ -83,6 +83,16 @@ peep([{gc_bif,_,_,_,_,Dst}=I|Is], SeenTests0, Acc) ->
%% Kill all remembered tests that depend on the destination register.
SeenTests = kill_seen(Dst, SeenTests0),
peep(Is, SeenTests, [I|Acc]);
+peep([{select,Op,R,F,Vls0}|Is], _, Acc) ->
+ case prune_redundant_values(Vls0, F) of
+ [] ->
+ %% No values left. Must convert to plain jump.
+ I = {jump,F},
+ peep(Is, gb_sets:empty(), [I|Acc]);
+ [_|_]=Vls ->
+ I = {select,Op,R,F,Vls},
+ peep(Is, gb_sets:empty(), [I|Acc])
+ end;
peep([{test,Op,_,Ops}=I|Is], SeenTests0, Acc) ->
case beam_utils:is_pure_test(I) of
false ->
@@ -127,3 +137,9 @@ kill_seen_1([{_,Ops}=Test|T], Dst) ->
false -> [Test|kill_seen_1(T, Dst)]
end;
kill_seen_1([], _) -> [].
+
+prune_redundant_values([_Val,F|Vls], F) ->
+ prune_redundant_values(Vls, F);
+prune_redundant_values([Val,Lbl|Vls], F) ->
+ [Val,Lbl|prune_redundant_values(Vls, F)];
+prune_redundant_values([], _) -> [].