Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
4422-Move-select_val-optimization-from-beam_pee...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4422-Move-select_val-optimization-from-beam_peep-to-beam_.patch of Package erlang
From e5d30f58ad6aab6c8940f044e57102fda309392b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Fri, 20 Aug 2021 07:13:31 +0200 Subject: [PATCH 2/7] Move select_val optimization from beam_peep to beam_jump As a preparation for removing the beam_peep pass, move optimization of select_val instructions from beam_peep to beam_jump. --- lib/compiler/src/beam_jump.erl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl index 6a10c25dbd..d7915d057a 100644 --- a/lib/compiler/src/beam_jump.erl +++ b/lib/compiler/src/beam_jump.erl @@ -629,6 +629,28 @@ opt([{test,_,{f,_}=Lbl,_}=I|Is], Acc, St) -> opt(Is, [I|Acc], label_used(Lbl, St)); opt([{test,_,{f,_}=Lbl,_,_,_}=I|Is], Acc, St) -> opt(Is, [I|Acc], label_used(Lbl, St)); +opt([{select,select_val,R,F,Vls0}|Is], Acc, St) -> + case prune_redundant_values(Vls0, F) of + [] -> + %% No values left. Must convert to plain jump. + I = {jump,F}, + opt([I|Is], Acc, St); + [{atom,_}=Value,Lbl] -> + %% Single value left. Convert to regular test. + Is1 = [{test,is_eq_exact,F,[R,Value]},{jump,Lbl}|Is], + opt(Is1, Acc, St); + [{integer,_}=Value,Lbl] -> + %% Single value left. Convert to regular test. + Is1 = [{test,is_eq_exact,F,[R,Value]},{jump,Lbl}|Is], + opt(Is1, Acc, St); + [{atom,B1},Lbl,{atom,B2},Lbl] when B1 =:= not B2 -> + %% Replace with is_boolean test. + Is1 = [{test,is_boolean,F,[R]},{jump,Lbl}|Is], + opt(Is1, Acc, St); + [_|_]=Vls -> + I = {select,select_val,R,F,Vls}, + skip_unreachable(Is, [I|Acc], label_used([F|Vls], St)) + end; opt([{select,_,_R,Fail,Vls}=I|Is], Acc, St) -> skip_unreachable(Is, [I|Acc], label_used([Fail|Vls], St)); opt([{label,From}=I,{label,To}|Is], Acc, #st{replace=Replace}=St) -> @@ -664,6 +686,12 @@ opt([], Acc, #st{replace=Replace0}) when Replace0 =/= #{} -> opt([], Acc, #st{replace=Replace}) when Replace =:= #{} -> reverse(Acc). +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([], _) -> []. + normalize_replace([{From,To0}|Rest], Replace, Acc) -> case Replace of #{To0 := To} -> -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor