From b241241f21bee111c9aac7185cb8fd9a751557bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 9 Sep 2018 06:30:23 +0200 Subject: beam_ssa_opt: Slightly optimize compile-time performance of CSE --- lib/compiler/src/beam_ssa_opt.erl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl index 6d94c38685..9289b76f28 100644 --- a/lib/compiler/src/beam_ssa_opt.erl +++ b/lib/compiler/src/beam_ssa_opt.erl @@ -417,7 +417,13 @@ cse_successors(_Is, Blk, Es, M) -> cse_successors_1([L|Ls], Es0, M) -> case M of + #{L:=Es1} when map_size(Es1) =:= 0 -> + %% The map is already empty. No need to do anything + %% since the intersection will be empty. + cse_successors_1(Ls, Es0, M); #{L:=Es1} -> + %% Calculate the intersection of the two maps. + %% Both keys and values must match. Es = maps:filter(fun(Key, Value) -> case Es1 of #{Key:=Value} -> true; -- cgit v1.2.3