File 2866-Eliminate-beam_utils-is_pure_test-1.patch of Package erlang

From b6c937ede74ae88c232ffb790998df594b41b28b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 20 Aug 2021 06:54:12 +0200
Subject: [PATCH 6/7] Eliminate beam_utils:is_pure_test/1

---
 lib/compiler/src/beam_jump.erl  | 18 +++---------------
 lib/compiler/src/beam_utils.erl | 29 +----------------------------
 2 files changed, 4 insertions(+), 43 deletions(-)

diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl
index d7915d057a..d060978a52 100644
--- a/lib/compiler/src/beam_jump.erl
+++ b/lib/compiler/src/beam_jump.erl
@@ -597,21 +597,9 @@ find_fixpoint(OptFun, Is0) ->
 	Is -> find_fixpoint(OptFun, Is)
     end.
 
-opt([{test,_,{f,L}=Lbl,_}=I|[{jump,{f,L}}|_]=Is], Acc, St) ->
-    %% We have
-    %%    Test Label Ops
-    %%    jump Label
-    %% The test instruction is not needed if the test is pure
-    %% (it modifies neither registers nor bit syntax state).
-    case beam_utils:is_pure_test(I) of
-	false ->
-	    %% Test is not pure; we must keep it.
-	    opt(Is, [I|Acc], label_used(Lbl, St));
-	true ->
-	    %% The test is pure and its failure label is the same
-	    %% as in the jump that follows -- thus it is not needed.
-	    opt(Is, Acc, St)
-    end;
+opt([{test,is_eq_exact,{f,L},_}|[{jump,{f,L}}|_]=Is], Acc, St) ->
+    %% The is_eq_exact test is not needed.
+    opt(Is, Acc, St);
 opt([{test,Test0,{f,L}=Lbl,Ops}=I|[{jump,To}|Is]=Is0], Acc, St) ->
     case is_label_defined(Is, L) of
 	false ->
diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl
index 437bc9b24a..816c29bc55 100644
--- a/lib/compiler/src/beam_utils.erl
+++ b/lib/compiler/src/beam_utils.erl
@@ -21,7 +21,7 @@
 %%
 
 -module(beam_utils).
--export([replace_labels/4,is_pure_test/1,split_even/1]).
+-export([replace_labels/4,split_even/1]).
 
 -export_type([code_index/0,module_code/0,instruction/0]).
 
@@ -39,11 +39,6 @@
 -type module_code() ::
         {module(),[_],[_],[int_function()],pos_integer()}.
 
-%% Internal types.
--type fail() :: beam_asm:fail() | 'fail'.
--type test() :: {'test',atom(),fail(),[beam_asm:src()]} |
-		{'test',atom(),fail(),integer(),list(),beam_asm:reg()}.
-
 %% replace_labels(FunctionIs, Tail, ReplaceDb, Fallback) -> FunctionIs.
 %%  Replace all labels in instructions according to the ReplaceDb.
 %%  If label is not found the Fallback is called with the label to
@@ -56,28 +51,6 @@
 replace_labels(Is, Acc, D, Fb) ->
     replace_labels_1(Is, Acc, D, Fb).
 
-%% is_pure_test({test,Op,Fail,Ops}) -> true|false.
-%%  Return 'true' if the test instruction does not modify any
-%%  registers and/or bit syntax matching state.
-%%
-
--spec is_pure_test(test()) -> boolean().
-
-is_pure_test({test,is_eq,_,[_,_]}) -> true;
-is_pure_test({test,is_ne,_,[_,_]}) -> true;
-is_pure_test({test,is_eq_exact,_,[_,_]}) -> true;
-is_pure_test({test,is_ne_exact,_,[_,_]}) -> true;
-is_pure_test({test,is_ge,_,[_,_]}) -> true;
-is_pure_test({test,is_lt,_,[_,_]}) -> true;
-is_pure_test({test,is_nonempty_list,_,[_]}) -> true;
-is_pure_test({test,is_tagged_tuple,_,[_,_,_]}) -> true;
-is_pure_test({test,test_arity,_,[_,_]}) -> true;
-is_pure_test({test,has_map_fields,_,[_|_]}) -> true;
-is_pure_test({test,is_bitstr,_,[_]}) -> true;
-is_pure_test({test,is_function2,_,[_,_]}) -> true;
-is_pure_test({test,Op,_,Ops}) ->
-    erl_internal:new_type_test(Op, length(Ops)).
-
 %% split_even/1
 %% [1,2,3,4,5,6] -> {[1,3,5],[2,4,6]}
 
-- 
2.31.1

openSUSE Build Service is sponsored by