diff options
author | Björn Gustavsson <[email protected]> | 2018-01-10 07:02:21 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-01-11 12:05:50 +0100 |
commit | 1a029efd1ad47f5736faa7f7be6780b649a8b257 (patch) | |
tree | 94a4ad2110f742540796aa9c061585837c23a1ed /lib/compiler/src/beam_block.erl | |
parent | 114f6de068f1cf5b0cf0cf1aacf2ff9a7f1f3650 (diff) | |
download | otp-1a029efd1ad47f5736faa7f7be6780b649a8b257.tar.gz otp-1a029efd1ad47f5736faa7f7be6780b649a8b257.tar.bz2 otp-1a029efd1ad47f5736faa7f7be6780b649a8b257.zip |
Run beam_block again after other optimizations have been run
Running beam_block again after the other optimizations have run will
give it more opportunities for optimizations. In particular, more
allocate_zero/2 instructions can be turned into allocate/2
instructions, and more get_tuple_element/3 instructions can store the
retrieved value into the correct register at once.
Out of a sample of about 700 modules in OTP, 64 modules were improved
by this commit.
Diffstat (limited to 'lib/compiler/src/beam_block.erl')
-rw-r--r-- | lib/compiler/src/beam_block.erl | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_block.erl b/lib/compiler/src/beam_block.erl index 7b3a95e03e..488485c17a 100644 --- a/lib/compiler/src/beam_block.erl +++ b/lib/compiler/src/beam_block.erl @@ -28,15 +28,21 @@ -spec module(beam_utils:module_code(), [compile:option()]) -> {'ok',beam_utils:module_code()}. -module({Mod,Exp,Attr,Fs0,Lc}, _Opt) -> - Fs = [function(F) || F <- Fs0], +module({Mod,Exp,Attr,Fs0,Lc}, Opts) -> + Blockify = not member(no_blockify, Opts), + Fs = [function(F, Blockify) || F <- Fs0], {ok,{Mod,Exp,Attr,Fs,Lc}}. -function({function,Name,Arity,CLabel,Is0}) -> +function({function,Name,Arity,CLabel,Is0}, Blockify) -> try %% Collect basic blocks and optimize them. - Is1 = blockify(Is0), - Is2 = embed_lines(Is1), + Is2 = case Blockify of + true -> + Is1 = blockify(Is0), + embed_lines(Is1); + false -> + Is0 + end, Is3 = beam_utils:anno_defs(Is2), Is4 = move_allocates(Is3), Is5 = beam_utils:live_opt(Is4), |