diff options
author | Michał Muskała <[email protected]> | 2017-11-23 21:27:40 +0100 |
---|---|---|
committer | Michał Muskała <[email protected]> | 2017-11-23 21:27:40 +0100 |
commit | 1cbc6a430d18d80a0b5e6ad0f7f1010d5394056a (patch) | |
tree | 9b53b78a1955d3d15e1258df57c615afea262efc | |
parent | 9556949af97553ad99133d2198b8d92c18de98c7 (diff) | |
download | otp-1cbc6a430d18d80a0b5e6ad0f7f1010d5394056a.tar.gz otp-1cbc6a430d18d80a0b5e6ad0f7f1010d5394056a.tar.bz2 otp-1cbc6a430d18d80a0b5e6ad0f7f1010d5394056a.zip |
Place move S x0 instructions at the end of blocks
The loader has a lot of fused instructions that include move S x0.
Placing them at the end of blocks makes it possible to take advantage
of this optimization more frequently.
-rw-r--r-- | lib/compiler/src/beam_block.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_block.erl b/lib/compiler/src/beam_block.erl index 6543e05e20..c640af224d 100644 --- a/lib/compiler/src/beam_block.erl +++ b/lib/compiler/src/beam_block.erl @@ -219,11 +219,20 @@ alloc_may_pass({set,_,_,{set_tuple_element,_}}) -> false; alloc_may_pass({set,_,_,put_list}) -> false; alloc_may_pass({set,_,_,put}) -> false; alloc_may_pass({set,_,_,_}) -> true. - + %% opt([Instruction]) -> [Instruction] %% Optimize the instruction stream inside a basic block. opt([{set,[X],[X],move}|Is]) -> opt(Is); +opt([{set,[X],_,move},{set,[X],_,move}=I|Is]) -> + opt([I|Is]); +opt([{set,[{x,0}],[S1],move}=I1,{set,[D2],[{x,0}],move}|Is]) -> + opt([I1,{set,[D2],[S1],move}|Is]); +opt([{set,[{x,0}],[S1],move}=I1,{set,[D2],[S2],move}|Is0]) when S1 =/= D2 -> + %% Place move S x0 at the end of move sequences so that + %% loader can merge with the following instruction + {Ds,Is} = opt_moves([D2], Is0), + [{set,Ds,[S2],move}|opt([I1|Is])]; opt([{set,_,_,{line,_}}=Line1, {set,[D1],[{integer,Idx1},Reg],{bif,element,{f,0}}}=I1, {set,_,_,{line,_}}=Line2, |