aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Muskała <[email protected]>2017-08-13 17:54:41 +0200
committerMichał Muskała <[email protected]>2017-08-14 14:24:04 +0200
commitcac51274eb9a550d5a3cc0e1b60591a9c2c1ffde (patch)
treef636f7708eb83f9a6bac2708d9ff94830a99c123
parent104c69e2153c41d5fb4eea86d18852d065258083 (diff)
downloadotp-cac51274eb9a550d5a3cc0e1b60591a9c2c1ffde.tar.gz
otp-cac51274eb9a550d5a3cc0e1b60591a9c2c1ffde.tar.bz2
otp-cac51274eb9a550d5a3cc0e1b60591a9c2c1ffde.zip
Apply the redundant test optimisation also in case of fall-through
Even though, it's not possible to have fall-throughs when entering the otp pass, it can produce them itself and we're running the pass until fixpoint.
-rw-r--r--lib/compiler/src/beam_jump.erl11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl
index c33de217bd..0bcec9ce19 100644
--- a/lib/compiler/src/beam_jump.erl
+++ b/lib/compiler/src/beam_jump.erl
@@ -336,6 +336,17 @@ opt([{test,_,{f,L}=Lbl,_}=I|[{label,L}|_]=Is], Acc0, St0) ->
{Acc,St} = opt_useless_loads(Acc0, L, St0),
opt(Is, Acc, St)
end;
+opt([{test,_,{f,L}=Lbl,_}=I|[{label,L}|_]=Is], Acc0, St0) ->
+ %% Similar to the above, except we have a fall-through rather than jump
+ %% Test Label Ops
+ %% label Label
+ case beam_utils:is_pure_test(I) of
+ false ->
+ opt(Is, [I|Acc0], label_used(Lbl, St0));
+ true ->
+ {Acc,St} = opt_useless_loads(Acc0, L, St0),
+ opt(Is, Acc, St)
+ end;
opt([{test,Test0,{f,L}=Lbl,Ops}=I|[{jump,To}|Is]=Is0], Acc, St) ->
case is_label_defined(Is, L) of
false ->