diff options
author | Björn Gustavsson <[email protected]> | 2018-01-12 10:36:42 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2018-01-12 10:36:42 +0100 |
commit | b4801ca7a48521b51e85e8013aad4570cb3ac25a (patch) | |
tree | 4469b0f35b08e76b2e8de7d42df142ca19231d11 /lib/compiler/src/beam_block.erl | |
parent | acb89a005be9be44a33dd3ce381a334299a1f3a4 (diff) | |
parent | 1a029efd1ad47f5736faa7f7be6780b649a8b257 (diff) | |
download | otp-b4801ca7a48521b51e85e8013aad4570cb3ac25a.tar.gz otp-b4801ca7a48521b51e85e8013aad4570cb3ac25a.tar.bz2 otp-b4801ca7a48521b51e85e8013aad4570cb3ac25a.zip |
Merge pull request #1680 from bjorng/bjorn/compiler/beam_block
Run beam_block a second time
Diffstat (limited to 'lib/compiler/src/beam_block.erl')
-rw-r--r-- | lib/compiler/src/beam_block.erl | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_block.erl b/lib/compiler/src/beam_block.erl index c8fea2069a..39ae8d5347 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), @@ -240,6 +246,10 @@ opt([{set,_,_,{line,_}}=Line1, {set,[D2],[{integer,Idx2},Reg],{bif,element,{f,0}}}=I2|Is]) when Idx1 < Idx2, D1 =/= D2, D1 =/= Reg, D2 =/= Reg -> opt([Line2,I2,Line1,I1|Is]); +opt([{set,[D1],[{integer,Idx1},Reg],{bif,element,{f,L}}}=I1, + {set,[D2],[{integer,Idx2},Reg],{bif,element,{f,L}}}=I2|Is]) + when Idx1 < Idx2, D1 =/= D2, D1 =/= Reg, D2 =/= Reg -> + opt([I2,I1|Is]); opt([{set,Ds0,Ss,Op}|Is0]) -> {Ds,Is} = opt_moves(Ds0, Is0), [{set,Ds,Ss,Op}|opt(Is)]; |