Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
1624-Optimize-Y-register-initialization.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1624-Optimize-Y-register-initialization.patch of Package erlang
From 267a04067b8fd5aad65e0a53c720965369559d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Tue, 29 Nov 2022 08:05:18 +0100 Subject: [PATCH 4/4] Optimize Y register initialization Delay initialization of Y register past a BIF that cannot fail and will not do a garbage collection. --- lib/compiler/src/beam_ssa_codegen.erl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/compiler/src/beam_ssa_codegen.erl b/lib/compiler/src/beam_ssa_codegen.erl index 869490e710..9a91f12b39 100644 --- a/lib/compiler/src/beam_ssa_codegen.erl +++ b/lib/compiler/src/beam_ssa_codegen.erl @@ -857,8 +857,34 @@ opt_allocate_defs([#cg_set{op=copy,dst=Dst}|Is], Regs) -> true -> [Dst|opt_allocate_defs(Is, Regs)]; false -> [] end; +opt_allocate_defs([#cg_set{anno=Anno,op={bif,Bif},args=Args,dst=Dst}|Is], Regs) -> + case is_gc_bif(Bif, Args) of + false -> + ArgTypes = maps:get(arg_types, Anno, #{}), + case is_yreg(Dst, Regs) andalso will_bif_succeed(Bif, Args, ArgTypes) of + true -> [Dst|opt_allocate_defs(Is, Regs)]; + false -> [] + end; + true -> + [] + end; opt_allocate_defs(_, _Regs) -> []. +will_bif_succeed(Bif, Args, ArgTypes) -> + Types = will_bif_succeed_types(Args, ArgTypes, 0), + case beam_call_types:will_succeed(erlang, Bif, Types) of + yes -> true; + _ -> false + end. + +will_bif_succeed_types([#b_literal{val=Val}|Args], ArgTypes, N) -> + Type = beam_types:make_type_from_value(Val), + [Type|will_bif_succeed_types(Args, ArgTypes, N + 1)]; +will_bif_succeed_types([#b_var{}|Args], ArgTypes, N) -> + Type = maps:get(N, ArgTypes, any), + [Type|will_bif_succeed_types(Args, ArgTypes, N + 1)]; +will_bif_succeed_types([], _, _) -> []. + opt_alloc_def([{L,#cg_blk{is=Is,last=Last}}|Bs], Ws0, Def0) -> case gb_sets:is_member(L, Ws0) of false -> -- 2.35.3
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