Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
3423-beam_ssa_dead-Avoid-unnecessary-sorting-of...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 3423-beam_ssa_dead-Avoid-unnecessary-sorting-of-the-switc.patch of Package erlang
From 17b90ce2f40b3f88e446e33320876a740d3df83d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Sun, 7 Mar 2021 08:15:35 +0100 Subject: [PATCH 3/3] beam_ssa_dead: Avoid unnecessary sorting of the switch list One of the invariants maintained by beam_ssa_lint is that the list of values and labels in a switch is sorted. Therefore, beam_ssa_dead can safely assume that the list is sorted, and can also avoid calling beam_ssa:normalize/1 after optimizations of switches that only update labels. --- lib/compiler/src/beam_ssa_dead.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/compiler/src/beam_ssa_dead.erl b/lib/compiler/src/beam_ssa_dead.erl index 037887529b..5ae3d89e6f 100644 --- a/lib/compiler/src/beam_ssa_dead.erl +++ b/lib/compiler/src/beam_ssa_dead.erl @@ -28,7 +28,7 @@ -include("beam_ssa.hrl"). -import(lists, [append/1,keymember/3,last/1,member/2, - reverse/1,sort/1,takewhile/2]). + reverse/1,takewhile/2]). -type used_vars() :: #{beam_ssa:label():=sets:set(beam_ssa:var_name())}. @@ -145,12 +145,17 @@ shortcut_terminator(#b_switch{arg=Bool,fail=Fail0,list=List0}=Sw, _Is, From, St) -> Fail = shortcut_sw_fail(Fail0, List0, Bool, From, St), List = shortcut_sw_list(List0, Bool, From, St), - beam_ssa:normalize(Sw#b_switch{fail=Fail,list=List}); + + %% There no need to call beam_ssa:normalize/1 (and invoke the + %% cost of sorting List), because the previous optimizations + %% could only have changed labels. + Sw#b_switch{fail=Fail,list=List}; shortcut_terminator(Last, _Is, _From, _St) -> Last. shortcut_sw_fail(Fail0, List, Bool, From, St0) -> - case sort(List) of + %% List has been sorted by beam_ssa:normalize/1. + case List of [{#b_literal{val=false},_}, {#b_literal{val=true},_}] -> RelOp = {{'not',is_boolean},Bool}, -- 2.26.2
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