diff options
author | Björn Gustavsson <[email protected]> | 2018-01-31 07:22:24 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-02-14 08:33:25 +0100 |
commit | 260d530946fd3eb2e2d7e74465a5095d35822128 (patch) | |
tree | 8b1b99aa283e434ad2c56d325d83717230be2381 /lib/compiler/src/beam_block.erl | |
parent | 54b76b437c9008b3aedbf3fd75526ad4719bde7d (diff) | |
download | otp-260d530946fd3eb2e2d7e74465a5095d35822128.tar.gz otp-260d530946fd3eb2e2d7e74465a5095d35822128.tar.bz2 otp-260d530946fd3eb2e2d7e74465a5095d35822128.zip |
beam_block: Combine blocks when running beam_block the second time
1a029efd1ad47f started to run the beam_block pass a second time,
but it did not attempt to combine adjacent blocks.
Combining adjacent blocks leads to many more opportunities for
optimizations.
After doing some diffing in generated code, it turns out that
there is no benefit for beam_split to split out line instructions
from blocks. It seems that the only reason it was done was to
slightly simplify the implementation of the no_line_info option
in beam_clean.
Diffstat (limited to 'lib/compiler/src/beam_block.erl')
-rw-r--r-- | lib/compiler/src/beam_block.erl | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/compiler/src/beam_block.erl b/lib/compiler/src/beam_block.erl index a4380a9314..47a2be8ab5 100644 --- a/lib/compiler/src/beam_block.erl +++ b/lib/compiler/src/beam_block.erl @@ -36,13 +36,11 @@ module({Mod,Exp,Attr,Fs0,Lc}, Opts) -> function({function,Name,Arity,CLabel,Is0}, Blockify) -> try %% Collect basic blocks and optimize them. - Is2 = case Blockify of - true -> - Is1 = blockify(Is0), - embed_lines(Is1); - false -> - Is0 + Is1 = case Blockify of + false -> Is0; + true -> blockify(Is0) end, + Is2 = embed_lines(Is1), Is3 = local_cse(Is2), Is4 = beam_utils:anno_defs(Is3), Is5 = move_allocates(Is4), @@ -139,6 +137,11 @@ embed_lines([{block,B2},{line,_}=Line,{block,B1}|T], Acc) -> embed_lines([{block,B1},{line,_}=Line|T], Acc) -> B = {block,[{set,[],[],Line}|B1]}, embed_lines([B|T], Acc); +embed_lines([{block,B2},{block,B1}|T], Acc) -> + %% This can only happen when beam_block is run for + %% the second time. + B = {block,B1++B2}, + embed_lines([B|T], Acc); embed_lines([I|Is], Acc) -> embed_lines(Is, [I|Acc]); embed_lines([], Acc) -> Acc. |