aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_peep.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-03-16 12:18:39 +0100
committerBjörn Gustavsson <[email protected]>2015-03-16 12:18:39 +0100
commit2617c55b3a4ef635812df7cb62f6710b235ad9ef (patch)
treed2767561f112ab70da883c28b1ef3398fe07fbd1 /lib/compiler/src/beam_peep.erl
parentf1da7597dec858ee26dc68a6da66eb62742f82bb (diff)
parentb4061dfd6ef6f84379fd8a0988eed79cb0bb1972 (diff)
downloadotp-2617c55b3a4ef635812df7cb62f6710b235ad9ef.tar.gz
otp-2617c55b3a4ef635812df7cb62f6710b235ad9ef.tar.bz2
otp-2617c55b3a4ef635812df7cb62f6710b235ad9ef.zip
Merge branch 'bjorn/compiler/optimizations'
* bjorn/compiler/optimizations: v3_life: Combine literal/2 and literal2/2 v3_codegen: Don't save options in the process dictionary Don't inline core_parse v3_core: Teach pat_alias/2 to eliminate duplicated variables beam_dead: Improve optimization by eliminating fallthroughs beam_dead: Optimize Var =:= Var beam_peep: Optimize away redundant use of is_boolean tests beam_bool: Correct initialized_regs/2 sys_core_fold: Generalize case optimization sys_core_fold: Improve optimization of 'not' sys_core_fold: Suppress compiler warnings when evaluating element/2 Clean up evaluation of setelement/3 Replace '==' with '=:=' when both operands are integers Update type information based on BIFs that returns integers sys_core_fold: Strengthen type optimization in lets
Diffstat (limited to 'lib/compiler/src/beam_peep.erl')
-rw-r--r--lib/compiler/src/beam_peep.erl15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/compiler/src/beam_peep.erl b/lib/compiler/src/beam_peep.erl
index 97a8c7ba70..5abacc8d5d 100644
--- a/lib/compiler/src/beam_peep.erl
+++ b/lib/compiler/src/beam_peep.erl
@@ -108,14 +108,14 @@ peep([{test,Op,_,Ops}=I|Is], SeenTests0, Acc) ->
%% has succeeded.
peep(Is, gb_sets:empty(), [I|Acc]);
true ->
- Test = {Op,Ops},
- case gb_sets:is_element(Test, SeenTests0) of
+ case is_test_redundant(Op, Ops, SeenTests0) of
true ->
- %% This test has already succeeded and
+ %% This test or a similar test has already succeeded and
%% is therefore redundant.
peep(Is, SeenTests0, Acc);
false ->
%% Remember that we have seen this test.
+ Test = {Op,Ops},
SeenTests = gb_sets:insert(Test, SeenTests0),
peep(Is, SeenTests, [I|Acc])
end
@@ -136,6 +136,15 @@ peep([I|Is], _, Acc) ->
peep(Is, gb_sets:empty(), [I|Acc]);
peep([], _, Acc) -> reverse(Acc).
+is_test_redundant(Op, Ops, Seen) ->
+ gb_sets:is_element({Op,Ops}, Seen) orelse
+ is_test_redundant_1(Op, Ops, Seen).
+
+is_test_redundant_1(is_boolean, [R], Seen) ->
+ gb_sets:is_element({is_eq_exact,[R,{atom,false}]}, Seen) orelse
+ gb_sets:is_element({is_eq_exact,[R,{atom,true}]}, Seen);
+is_test_redundant_1(_, _, _) -> false.
+
kill_seen(Dst, Seen0) ->
gb_sets:from_ordset(kill_seen_1(gb_sets:to_list(Seen0), Dst)).